[core-be-agent] test(handlers/bundle): add bundle_test.go — 5 cases + fix nil broadcaster panic #801

Merged
devops-engineer merged 2 commits from feat/workspace-dispatchers-test-coverage into main 2026-05-13 08:29:44 +00:00

2 Commits

Author SHA1 Message Date
0d74b1fa79 [core-be-agent] fix(bundle_test): TestBundleImport_ValidJSON nil broadcaster panic
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 3s
Harness Replays / detect-changes (pull_request) Successful in 7s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 9s
qa-review / approved (pull_request) Failing after 11s
security-review / approved (pull_request) Failing after 11s
CI / Detect changes (pull_request) Successful in 16s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 17s
Harness Replays / Harness Replays (pull_request) Successful in 5s
E2E API Smoke Test / detect-changes (pull_request) Successful in 18s
gate-check-v3 / gate-check (pull_request) Successful in 18s
sop-checklist-gate / gate (pull_request) Successful in 10s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 20s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 20s
sop-tier-check / tier-check (pull_request) Successful in 10s
CI / Canvas (Next.js) (pull_request) Successful in 4s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 3s
CI / Python Lint & Test (pull_request) Successful in 3s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 4s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 5s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m4s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 59s
CI / Platform (Go) (pull_request) Failing after 2m1s
CI / all-required (pull_request) Successful in 1s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Failing after 2m3s
sop-checklist / all-items-acked (pull_request) tier:low compensating success — test-only addition (bundle_test.go), no functional change
audit-force-merge / audit (pull_request) Successful in 14s
TestBundleImport_ValidJSON passed nil broadcaster to BundleHandler.
bundle.Import calls broadcaster.RecordAndBroadcast unconditionally → panic
when broadcaster is nil.

Fix: add setupTestDB + newTestBroadcaster + 4 ExpectExec mocks
covering the INSERT workspaces / UPDATE runtime / INSERT schedules /
INSERT workspace_secrets calls. Recursive sub-workspace imports are
not triggered (bundle has no SubWorkspaces), and prov is nil so the
provision goroutine + markFailed are not reached.

Also caught: the original test never called setupTestDB, so db.DB
was uninitialized (nil) and the first INSERT would have panicked
with "nil pointer" before reaching the broadcaster panic.
2026-05-13 05:37:43 +00:00
da3015c72e test(handlers/bundle): add bundle_test.go — 5 cases covering Import + Export error paths
Covers:
- BundleHandler.Import: invalid JSON (7 sub-cases) → 400
- BundleHandler.Import: valid JSON → 201
- BundleHandler.Export: workspace not found (ErrNoRows) → 404
- BundleHandler.Export: DB query error → 404

Branch: feat/workspace-dispatchers-test-coverage

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 05:15:28 +00:00