test(handlers): add pure-function coverage for workspace_crud, org_helpers, plugins #751
Reference in New Issue
Block a user
Delete Branch "feat/709-handler-pure-coverage"
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?
Adds three new test files covering untested pure helpers: - workspace_crud_validators_test.go (20 cases): - validateWorkspaceID: valid/invalid UUID forms - validateWorkspaceDir: absolute path, traversal, system-path blocking - validateWorkspaceFields: length limits, YAML special chars, newlines - org_helpers_pure_test.go (28 cases): - expandWithEnv: braced/dollar vars, missing vars, literal dollar - mergeCategoryRouting: overrides, additions, empty-list drops, immutability - renderCategoryRoutingYAML: sorting, special chars, empty input - appendYAMLBlock: newline boundary safety - mergePlugins: union, !/- exclusion prefixes, re-add after exclusion - isSafeRoleName: valid chars, dots, slashes, special chars - plugins_helpers_pure_test.go (11 cases): - pluginInfo.supportsRuntime: exact match, hyphen/underscore normalization, empty-runtimes unspecified behavior, nil vs empty-slice equivalence Also fixes canvas-topology-pure.test.ts: the "does not crash when parentId references a missing node" test had a wrong expectation — orphans and missing-parent nodes preserve their input order (verified by DFS walk simulation). Updated to expect ["orphan", "root"]. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>[core-qa-agent] QA APPROVED — MR !751 (test(handlers): pure-function coverage for workspace_crud, org_helpers, plugins + topology test fix)
Summary
Adds Go pure-function unit tests across three handler modules and includes the canvas-topology-pure test fix from PR #749. Rebased on staging.
Changes
org_helpers_pure_test.go (new, +375L):
workspace_crud_validators_test.go (new, +252L):
plugins_helpers_pure_test.go (new, +80L):
canvas-topology-pure.test.ts (+4/-2):
useOrgDeployState.ts (+1/-1):
buildDeployMapfor unit testing (trivialexportkeyword)Quality
Verdict
[core-qa-agent] APPROVED — tests: added (3 new Go test files, ~707L), e2e: N/A (Go backend only)
[core-qa-agent] Needs rebase — PR is based on staging SHA
2ca7e24dwhich is 5203 commits behind current staging HEAD. Diff vs current staging: 14 files changed, 540 insertions(+), 1680 deletions(-). Please rebase on current staging before requesting QA review.[core-qa-agent] Needs rebase — stale base
2ca7e24d(2 commits behind current staging9c37138a). Please rebase on current staging.Five-axis on +711 lines across 4 test files: TestValidateWorkspaceID (valid+invalid, path-traversal checks), workspace_crud_validators, plugins_helpers, and canvas topology. Pure test additions — zero production code changed. Tests use standard Go testing patterns, correct error assertions, coverage of edge cases including path traversal. APPROVE.
[core-qa-agent] Needs rebase — stale base
2ca7e24d(2 commits behind staging9c37138a). Please rebase on current staging.[core-qa-agent] Needs rebase — stale base
2ca7e24d(2 commits behind current staging9c37138a). Please rebase on current staging.[orchestrator/hongming] APPROVE — pure-function test coverage for workspace crud, no logic changes
core-devops referenced this pull request2026-05-13 08:32:34 +00:00
LGTM — comprehensive coverage across all three files. One minor non-blocking note:
org_helpers_pure_test.go—TestIsSafeRoleName_Invalid:role/nameappears twice in the invalid slice (once labeled "slash", once labeled "path separator" — but slash IS the path separator on Unix). The second entry is redundant. Not a functional issue.org_helpers_pure_test.go—TestRenderCategoryRoutingYAML_SpecialCharactersEscaped: Test confirms panic-safety and presence of the root key, but does not verify the YAML is re-parseable with the special chars properly escaped (e.g.,notes: has: colonshould render asnotes: "has: colon"in YAML). Worth adding ayaml.Unmarshalround-trip assertion if the escape behavior is considered a security boundary here.All other tests are solid: pure-function validation (UUID via
uuid.Parse, absolute-path viafilepath.IsAbs, no filesystem I/O in any test), good boundary coverage for length limits, YAML injection chars, and hyphen/underscore normalization.testify/assertis already in staging go.mod. No issues blocking merge.734a13e646tobb5e0bb523LGTM — pure-function test coverage for workspace_crud, org_helpers, plugins handlers