[core-be-agent] fix tests: routing r2→r for delete/resolve, CascadeDelete WithArgs
Some checks failed
CI / Canvas Deploy Reminder (pull_request) Blocked by required conditions
CI / all-required (pull_request) Blocked by required conditions
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 12s
CI / Detect changes (pull_request) Successful in 29s
E2E Staging SaaS (full lifecycle) / E2E Staging SaaS (pull_request) Has been skipped
E2E API Smoke Test / detect-changes (pull_request) Successful in 32s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 29s
Harness Replays / detect-changes (pull_request) Successful in 17s
Lint curl status-code capture / Scan workflows for curl status-capture pollution (pull_request) Successful in 13s
E2E Staging SaaS (full lifecycle) / pr-validate (pull_request) Successful in 46s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 42s
lint-continue-on-error-tracking / lint-continue-on-error-tracking (pull_request) Successful in 1m52s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m15s
lint-mask-pr-atomicity / lint-mask-pr-atomicity (pull_request) Successful in 2m3s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 17s
Lint pre-flip continue-on-error / Verify continue-on-error flips have run-log proof (pull_request) Successful in 2m0s
gate-check-v3 / gate-check (pull_request) Failing after 27s
security-review / approved (pull_request) Failing after 18s
qa-review / approved (pull_request) Failing after 20s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 40s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: 7
sop-checklist-gate / gate (pull_request) Successful in 13s
sop-tier-check / tier-check (pull_request) Successful in 17s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 18s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 8s
Harness Replays / Harness Replays (pull_request) Successful in 5s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 19s
CI / Python Lint & Test (pull_request) Successful in 7m59s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Failing after 13m15s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Failing after 12m26s
lint-required-context-exists-in-bp / lint-required-context-exists-in-bp (pull_request) Failing after 15m54s
Lint workflow YAML (Gitea-1.22.6-hostile shapes) / Lint workflow YAML for Gitea-1.22.6-hostile shapes (pull_request) Failing after 15m4s
CI / Platform (Go) (pull_request) Failing after 13m56s
CI / Canvas (Next.js) (pull_request) Failing after 18m48s
Some checks failed
CI / Canvas Deploy Reminder (pull_request) Blocked by required conditions
CI / all-required (pull_request) Blocked by required conditions
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 12s
CI / Detect changes (pull_request) Successful in 29s
E2E Staging SaaS (full lifecycle) / E2E Staging SaaS (pull_request) Has been skipped
E2E API Smoke Test / detect-changes (pull_request) Successful in 32s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 29s
Harness Replays / detect-changes (pull_request) Successful in 17s
Lint curl status-code capture / Scan workflows for curl status-capture pollution (pull_request) Successful in 13s
E2E Staging SaaS (full lifecycle) / pr-validate (pull_request) Successful in 46s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 42s
lint-continue-on-error-tracking / lint-continue-on-error-tracking (pull_request) Successful in 1m52s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m15s
lint-mask-pr-atomicity / lint-mask-pr-atomicity (pull_request) Successful in 2m3s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 17s
Lint pre-flip continue-on-error / Verify continue-on-error flips have run-log proof (pull_request) Successful in 2m0s
gate-check-v3 / gate-check (pull_request) Failing after 27s
security-review / approved (pull_request) Failing after 18s
qa-review / approved (pull_request) Failing after 20s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 40s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: 7
sop-checklist-gate / gate (pull_request) Successful in 13s
sop-tier-check / tier-check (pull_request) Successful in 17s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 18s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 8s
Harness Replays / Harness Replays (pull_request) Successful in 5s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 19s
CI / Python Lint & Test (pull_request) Successful in 7m59s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Failing after 13m15s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Failing after 12m26s
lint-required-context-exists-in-bp / lint-required-context-exists-in-bp (pull_request) Failing after 15m54s
Lint workflow YAML (Gitea-1.22.6-hostile shapes) / Lint workflow YAML for Gitea-1.22.6-hostile shapes (pull_request) Failing after 15m4s
CI / Platform (Go) (pull_request) Failing after 13m56s
CI / Canvas (Next.js) (pull_request) Failing after 18m48s
- workspace_crud_test.go: TestDelete_* tests registered routes on r2 but called r.ServeHTTP, causing unmocked DB calls. TestUpdate_WorkspaceNotFound same. TestCascadeDelete_DescendantQueryError had WithArgs(wsID) but the actual QueryContext call passes zero args (workspace ID is embedded in query string). - instructions_test.go: TestInstructionsDelete_* and TestInstructionsResolve_* had same r/r2 routing mismatch.
This commit is contained in:
parent
dcef8d3a79
commit
811d76d27a
@ -440,8 +440,7 @@ func TestInstructionsUpdate_UpdateError(t *testing.T) {
|
||||
func TestInstructionsDelete_HappyPath(t *testing.T) {
|
||||
mock, r := setupInstructionsTest(t)
|
||||
h := NewInstructionsHandler()
|
||||
r2 := gin.New()
|
||||
r2.DELETE("/instructions/:id", h.Delete)
|
||||
r.DELETE("/instructions/:id", h.Delete)
|
||||
|
||||
mock.ExpectExec(`DELETE FROM platform_instructions WHERE id = \$1`).
|
||||
WithArgs("inst-123").
|
||||
@ -459,8 +458,7 @@ func TestInstructionsDelete_HappyPath(t *testing.T) {
|
||||
func TestInstructionsDelete_NotFound(t *testing.T) {
|
||||
mock, r := setupInstructionsTest(t)
|
||||
h := NewInstructionsHandler()
|
||||
r2 := gin.New()
|
||||
r2.DELETE("/instructions/:id", h.Delete)
|
||||
r.DELETE("/instructions/:id", h.Delete)
|
||||
|
||||
mock.ExpectExec(`DELETE FROM platform_instructions WHERE id = \$1`).
|
||||
WithArgs("nonexistent").
|
||||
@ -478,8 +476,7 @@ func TestInstructionsDelete_NotFound(t *testing.T) {
|
||||
func TestInstructionsDelete_DeleteError(t *testing.T) {
|
||||
mock, r := setupInstructionsTest(t)
|
||||
h := NewInstructionsHandler()
|
||||
r2 := gin.New()
|
||||
r2.DELETE("/instructions/:id", h.Delete)
|
||||
r.DELETE("/instructions/:id", h.Delete)
|
||||
|
||||
mock.ExpectExec(`DELETE FROM platform_instructions WHERE id = \$1`).
|
||||
WillReturnError(sql.ErrConnDone)
|
||||
@ -498,8 +495,7 @@ func TestInstructionsDelete_DeleteError(t *testing.T) {
|
||||
func TestInstructionsResolve_NoInstructions(t *testing.T) {
|
||||
mock, r := setupInstructionsTest(t)
|
||||
h := NewInstructionsHandler()
|
||||
r2 := gin.New()
|
||||
r2.GET("/workspaces/:id/instructions/resolve", h.Resolve)
|
||||
r.GET("/workspaces/:id/instructions/resolve", h.Resolve)
|
||||
|
||||
mock.ExpectQuery(`SELECT scope, title, content FROM platform_instructions`).
|
||||
WithArgs("ws-uuid-123").
|
||||
@ -528,8 +524,7 @@ func TestInstructionsResolve_NoInstructions(t *testing.T) {
|
||||
func TestInstructionsResolve_GlobalOnly(t *testing.T) {
|
||||
mock, r := setupInstructionsTest(t)
|
||||
h := NewInstructionsHandler()
|
||||
r2 := gin.New()
|
||||
r2.GET("/workspaces/:id/instructions/resolve", h.Resolve)
|
||||
r.GET("/workspaces/:id/instructions/resolve", h.Resolve)
|
||||
|
||||
mock.ExpectQuery(`SELECT scope, title, content FROM platform_instructions`).
|
||||
WithArgs("ws-uuid-123").
|
||||
@ -556,8 +551,7 @@ func TestInstructionsResolve_GlobalOnly(t *testing.T) {
|
||||
func TestInstructionsResolve_GlobalPlusWorkspace(t *testing.T) {
|
||||
mock, r := setupInstructionsTest(t)
|
||||
h := NewInstructionsHandler()
|
||||
r2 := gin.New()
|
||||
r2.GET("/workspaces/:id/instructions/resolve", h.Resolve)
|
||||
r.GET("/workspaces/:id/instructions/resolve", h.Resolve)
|
||||
|
||||
mock.ExpectQuery(`SELECT scope, title, content FROM platform_instructions`).
|
||||
WithArgs("ws-uuid-123").
|
||||
@ -589,8 +583,7 @@ func TestInstructionsResolve_GlobalPlusWorkspace(t *testing.T) {
|
||||
func TestInstructionsResolve_QueryError(t *testing.T) {
|
||||
mock, r := setupInstructionsTest(t)
|
||||
h := NewInstructionsHandler()
|
||||
r2 := gin.New()
|
||||
r2.GET("/workspaces/:id/instructions/resolve", h.Resolve)
|
||||
r.GET("/workspaces/:id/instructions/resolve", h.Resolve)
|
||||
|
||||
mock.ExpectQuery(`SELECT scope, title, content FROM platform_instructions`).
|
||||
WithArgs("ws-uuid-123").
|
||||
@ -608,8 +601,7 @@ func TestInstructionsResolve_QueryError(t *testing.T) {
|
||||
func TestInstructionsResolve_MissingWorkspaceID(t *testing.T) {
|
||||
_, r := setupInstructionsTest(t)
|
||||
h := NewInstructionsHandler()
|
||||
r2 := gin.New()
|
||||
r2.GET("/workspaces/:id/instructions/resolve", h.Resolve)
|
||||
r.GET("/workspaces/:id/instructions/resolve", h.Resolve)
|
||||
|
||||
// Empty workspace ID
|
||||
req, _ := http.NewRequest("GET", "/workspaces//instructions/resolve", nil)
|
||||
|
||||
@ -215,8 +215,7 @@ func TestUpdate_InvalidBody(t *testing.T) {
|
||||
func TestUpdate_WorkspaceNotFound(t *testing.T) {
|
||||
mock, r := setupWorkspaceCrudTest(t)
|
||||
h := NewWorkspaceHandler(nil, nil, nil, nil)
|
||||
r2 := gin.New()
|
||||
r2.PATCH("/workspaces/:id", h.Update)
|
||||
r.PATCH("/workspaces/:id", h.Update)
|
||||
|
||||
wsID := "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
|
||||
|
||||
@ -229,7 +228,7 @@ func TestUpdate_WorkspaceNotFound(t *testing.T) {
|
||||
req, _ := http.NewRequest("PATCH", "/workspaces/"+wsID, bytes.NewReader(b))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
w := httptest.NewRecorder()
|
||||
r2.ServeHTTP(w, req)
|
||||
r.ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusNotFound {
|
||||
t.Errorf("expected 404, got %d: %s", w.Code, w.Body.String())
|
||||
@ -375,12 +374,11 @@ func TestUpdate_WorkspaceDirRelativePath(t *testing.T) {
|
||||
func TestDelete_InvalidUUID(t *testing.T) {
|
||||
_, r := setupWorkspaceCrudTest(t)
|
||||
h := NewWorkspaceHandler(nil, nil, nil, nil)
|
||||
r2 := gin.New()
|
||||
r2.DELETE("/workspaces/:id", h.Delete)
|
||||
r.DELETE("/workspaces/:id", h.Delete)
|
||||
|
||||
req, _ := http.NewRequest("DELETE", "/workspaces/not-a-uuid", nil)
|
||||
w := httptest.NewRecorder()
|
||||
r2.ServeHTTP(w, req)
|
||||
r.ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Errorf("expected 400, got %d: %s", w.Code, w.Body.String())
|
||||
@ -390,8 +388,7 @@ func TestDelete_InvalidUUID(t *testing.T) {
|
||||
func TestDelete_HasChildrenWithoutConfirm(t *testing.T) {
|
||||
mock, r := setupWorkspaceCrudTest(t)
|
||||
h := NewWorkspaceHandler(nil, nil, nil, nil)
|
||||
r2 := gin.New()
|
||||
r2.DELETE("/workspaces/:id", h.Delete)
|
||||
r.DELETE("/workspaces/:id", h.Delete)
|
||||
|
||||
wsID := "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
|
||||
|
||||
@ -403,7 +400,7 @@ func TestDelete_HasChildrenWithoutConfirm(t *testing.T) {
|
||||
req, _ := http.NewRequest("DELETE", "/workspaces/"+wsID, nil)
|
||||
// No ?confirm=true
|
||||
w := httptest.NewRecorder()
|
||||
r2.ServeHTTP(w, req)
|
||||
r.ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusConflict {
|
||||
t.Errorf("expected 409, got %d: %s", w.Code, w.Body.String())
|
||||
@ -424,8 +421,7 @@ func TestDelete_HasChildrenWithoutConfirm(t *testing.T) {
|
||||
func TestDelete_ChildrenCheckQueryError(t *testing.T) {
|
||||
mock, r := setupWorkspaceCrudTest(t)
|
||||
h := NewWorkspaceHandler(nil, nil, nil, nil)
|
||||
r2 := gin.New()
|
||||
r2.DELETE("/workspaces/:id", h.Delete)
|
||||
r.DELETE("/workspaces/:id", h.Delete)
|
||||
|
||||
wsID := "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
|
||||
|
||||
@ -435,7 +431,7 @@ func TestDelete_ChildrenCheckQueryError(t *testing.T) {
|
||||
|
||||
req, _ := http.NewRequest("DELETE", "/workspaces/"+wsID, nil)
|
||||
w := httptest.NewRecorder()
|
||||
r2.ServeHTTP(w, req)
|
||||
r.ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusInternalServerError {
|
||||
t.Errorf("expected 500, got %d", w.Code)
|
||||
@ -572,15 +568,17 @@ func TestCascadeDelete_InvalidUUID(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCascadeDelete_DescendantQueryError(t *testing.T) {
|
||||
mock, _ := setupWorkspaceCrudTest(t)
|
||||
mock, r := setupWorkspaceCrudTest(t)
|
||||
wsID := "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
|
||||
_ = r
|
||||
|
||||
// CascadeDelete returns early on descendant query error — nil deps for
|
||||
// StopWorkspace/RemoveVolume/broadcaster are fine since they are never
|
||||
// reached in this error path.
|
||||
h := &WorkspaceHandler{}
|
||||
// Note: the descendant CTE query is called with zero args (workspace ID
|
||||
// is embedded in the query string, not passed as a query arg).
|
||||
mock.ExpectQuery(`WITH RECURSIVE descendants AS`).
|
||||
WithArgs(wsID).
|
||||
WillReturnError(sql.ErrConnDone)
|
||||
|
||||
deleted, stopErrs, err := h.CascadeDelete(context.Background(), wsID)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user