test(handlers): coverage for matchesChatID + TemplateImageRef (core#1988) #2583
Reference in New Issue
Block a user
Delete Branch "test/core-1988-matcheschatid-templateimageref"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Replaces 0%-coverage gaps in two small pure helpers.
matchesChatID(channels.go): table-driven tests for exact match, comma-separated list, whitespace trimming, missing key, wrong type, substring non-match, empty string edge cases.TemplateImageRef(admin_workspace_images.go): verifies default registry prefix, custom ECR mirror, self-hosted Gitea registry, and hyphenated runtime names.No DB or HTTP setup required — hermetic and fast.
Fixes #1988
Test plan:
go test ./workspace-server/internal/handlers/ -run TestMatchesChatID -vpassesgo test ./workspace-server/internal/handlers/ -run TestTemplateImageRef -vpassesCo-Authored-By: Claude noreply@anthropic.com
5-axis review (CR3) on head
cf17c82a5f:Correctness: test-only change adds table-driven coverage for two pure helpers.
matchesChatIDcases cover exact match, comma-separated membership, whitespace trimming, missing/wrong config, substring rejection, and empty inputs.TemplateImageRefcases cover default prefix, ECR mirror, Gitea registry, and hyphenated runtimes; these match the implementation's RegistryPrefix + workspace-template naming contract.Robustness: hermetic unit tests with
t.Setenv; no DB, HTTP, external service, or global state leakage beyond test-scoped env.Security: no production auth/secret handling changed; the added assertions help guard routing/image-reference helper behavior. Secret scan is green.
Performance: tests are small table-driven unit tests, no slow fixtures.
Readability: cases are named, focused, and easy to extend.
Verdict: APPROVED. Note: merge remains gate-dependent; I will not merge over standing required-red/operator-shadow statuses.
APPROVED — 5-axis review on head
cf17c82a5f.Correctness: Test-only diff in two
_test.gofiles.TestTemplateImageRefcovers default registry, custom ECR/Gitea prefixes, and hyphenated runtimes against the productionTemplateImageRefformatting.TestMatchesChatIDcovers exact match, comma-separated membership, whitespace trimming, missing/wrong-type config, substring non-match, and empty values, matching the helper's exact split+trim behavior.Robustness: Table-driven cases are deterministic and use
t.Setenv, so env mutation is scoped per test case. No network, clock, database, or fixture flake risk introduced.Security: No production/auth/secret behavior changes. The
matchesChatIDsubstring non-match case usefully guards against overbroad channel matching.Performance: Unit tests are small and local-only; no material CI cost.
Readability: Cases are named clearly and assertions are direct.
CI classification:
CI / all-requiredis green. The visible SOPpull_request0/7 red is the known untrusted shadow class while trustedpull_request_targetSOP is green. QA/security review gates are review-trigger related; Local Provision real-image red is advisory.CR-A genuine review @ head
cf17c82a— APPROVE (test-only).Two new test files, +111/-0, no production code touched:
TestTemplateImageRef— 4 cases: default ghcr prefix, custom ECR mirror, self-hosted Gitea registry, hyphenated runtime name; usest.Setenv("MOLECULE_IMAGE_REGISTRY", …)(auto-cleanup). Registry-prefix composition asserted correctly.TestMatchesChatID— 8 cases with the correct guards: exact, comma-list membership, whitespace-trim, missing key, wrong-type int → false, substring non-match → false, empty config value, empty query. The substring/wrong-type cases are exactly what locks the intended semantics (no naive Contains, no type coercion).5-axis: Correctness ✓ (assertions match documented behavior), Robustness ✓ (table-driven subtests, t.Setenv), Security ✓ (no secret-shaped strings — the ECR account id is a placeholder; secret-scan green), Performance ✓, Readability ✓. Required CI green (E2E API Smoke, Handlers-PG, all-required, gate-check-v3).
Approving as a distinct 3rd reviewer — this also re-fires the
pull_request_reviewevent to refresh the qa/security team-gate runs (the prior review-variant runs were stuck pending).CR-A re-fire: re-issuing approval to re-trigger the wedged security-review
pull_request_reviewgate run (prior run 348038/job 469196 was stuck at startup with no runner). Verdict unchanged — APPROVE (clean test-only, 3-distinct, all other required green).