Skip to content

test: add unit tests for gh.zig and tools.zig (#167)#412

Open
yxlyx wants to merge 1 commit intomainfrom
test/167-gh-tools-unit-tests
Open

test: add unit tests for gh.zig and tools.zig (#167)#412
yxlyx wants to merge 1 commit intomainfrom
test/167-gh-tools-unit-tests

Conversation

@yxlyx
Copy link
Copy Markdown
Collaborator

@yxlyx yxlyx commented Apr 10, 2026

Summary

gh.zig — 12 new tests (from zero)

  • classifyError: auth required (3 patterns), not found (3), rate limited (3), permission denied (3), unexpected (3 including empty string)
  • classifyError priority ordering: auth > not-found > rate-limit
  • errorMessage: all 8 variants return non-empty strings + specific string assertions
  • containsAny: basic matching + empty inputs
  • GhResult.deinit: memory safety with testing allocator

tools.zig — 5 new tests

  • parse: valid tool names round-trip correctly
  • parse: invalid/empty/uppercase names return null
  • parse: every Tool enum variant round-trips through @tagName
  • dispatch: enum variant count assertion (36) for switch coverage
  • tools_list: JSON contains expected tool names

Test plan

  • zig test src/gh.zig — 12/12 tests pass
  • zig ast-check src/tools.zig — clean parse
  • tools.zig tests require full build system (mcp module); syntax verified via ast-check

Closes #167

gh.zig — 12 new tests (from zero):
- classifyError: auth required (3 patterns), not found (3), rate limited (3),
  permission denied (3), unexpected (3 including empty string)
- classifyError priority: auth > not-found > rate-limit
- errorMessage: all 8 variants return non-empty strings
- errorMessage: specific string assertions for AuthRequired, NotFound, Unexpected
- containsAny: basic matching, empty inputs
- GhResult.deinit: memory safety with testing allocator

tools.zig — 5 new tests:
- parse: valid tool names round-trip
- parse: invalid/empty/uppercase names return null
- parse: every Tool enum variant round-trips through @TagName
- dispatch: enum variant count assertion (36) for switch coverage
- tools_list: JSON contains expected tool names

Made-with: Cursor
@yxlyx yxlyx force-pushed the test/167-gh-tools-unit-tests branch from a384076 to 911fa69 Compare April 10, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: add unit tests for gh.zig and tools.zig

1 participant