Skip to content

test(opencode): add unit coverage for permission mapping helpers#1050

Merged
aaight merged 1 commit intodevfrom
feature/opencode-permissions-unit-tests
Mar 25, 2026
Merged

test(opencode): add unit coverage for permission mapping helpers#1050
aaight merged 1 commit intodevfrom
feature/opencode-permissions-unit-tests

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 25, 2026

Summary

  • Adds tests/unit/backends/opencode-permissions.test.ts with 35 unit tests covering the three pure helper functions in src/backends/opencode/permissions.ts
  • Tests verify allow/deny behavior for all five permission types: edit, bash, webfetch, external_directory, and doom_loop
  • Asserts that unknown permission types always resolve to deny
  • Includes integration-style tests that pipe buildPermissionConfig output directly into resolvePermissionDecision

Card: https://trello.com/c/nWKVcaVe/562-as-a-developer-i-want-unit-coverage-for-opencode-permission-mapping-so-that-tool-approval-behavior-stays-deterministic

Test plan

  • buildPermissionConfig — covers default deny, capability-gated allow for edit/bash/webfetch, unconditional deny for doom_loop/external_directory
  • normalizePermissionDecision — maps allow → always and deny → reject
  • resolvePermissionDecision — per-type allow/deny routing for all five known types; unknown types resolve to deny
  • Integration group — verifies the full buildPermissionConfig → resolvePermissionDecision pipeline
  • vitest run --project unit-backends tests/unit/backends/opencode-permissions.test.ts passes (35/35)
  • npm run lint — no errors
  • npm run typecheck — no errors

🤖 Generated with Claude Code

🕵️ claude-code · claude-sonnet-4-6 · run details

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — Clean, thorough unit test coverage for three small pure functions. Tests correctly mirror the source implementation in src/backends/opencode/permissions.ts, covering all five permission types across all three helpers plus an integration group that validates the pipeline. All 35 tests pass, CI is green, and the file follows existing test conventions in tests/unit/backends/.

🕵️ claude-code · claude-opus-4-6 · run details

@aaight aaight merged commit afdf7d1 into dev Mar 25, 2026
9 checks passed
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.

2 participants