From 279ed687df1418ed2c9dab9c26177d5c23156344 Mon Sep 17 00:00:00 2001 From: Molecule AI Core-DevOps Date: Thu, 14 May 2026 23:20:57 +0000 Subject: [PATCH] fix(tests): restore correct assertions broken by merge conflict resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two test assertions were corrupted during merge conflict resolution in 9ce48488 (CWE-78 guard + rows.Err merge): 1. TestInstructionsHandler_Create_Success: mock returns new-inst-id (the ID the handler would generate) but assertion still expected new-inst-1. Fix: align assertion with mock. 2. TestInstructionsList_ByWorkspaceID: merge changed expected count from 2 to 0, but the handler correctly returns both global + workspace-scoped instructions for a workspace_id (scope = 'global' OR scope = 'workspace' AND scope_target = $1). The original test expected 2 and verified the first row was global. Fix: restore original expected count + scope check. Both bugs are pre-existing in the test file — the underlying handler logic is correct. Tests pass locally. Fixes: molecule-core#1090 (main-red) Co-Authored-By: Claude Opus 4.7 --- .../internal/handlers/instructions_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/workspace-server/internal/handlers/instructions_test.go b/workspace-server/internal/handlers/instructions_test.go index fdff08d6..a09dc106 100644 --- a/workspace-server/internal/handlers/instructions_test.go +++ b/workspace-server/internal/handlers/instructions_test.go @@ -86,8 +86,11 @@ func TestInstructionsList_ByWorkspaceID(t *testing.T) { if err := json.Unmarshal(w.Body.Bytes(), &result); err != nil { t.Fatalf("invalid JSON: %v", err) } - if len(result) != 0 { - t.Fatalf("expected 0 instructions, got %d", len(result)) + if len(result) != 2 { + t.Fatalf("expected 2 instructions, got %d", len(result)) + } + if result[0].Scope != "global" { + t.Errorf("first row scope: expected global, got %s", result[0].Scope) } if err := mock.ExpectationsWereMet(); err != nil { t.Fatalf("unmet expectations: %v", err) @@ -216,8 +219,8 @@ func TestInstructionsHandler_Create_Success(t *testing.T) { if err := json.Unmarshal(w.Body.Bytes(), &out); err != nil { t.Fatalf("response not valid JSON: %v", err) } - if out["id"] != "new-inst-1" { - t.Errorf("expected id new-inst-1, got %s", out["id"]) + if out["id"] != "new-inst-id" { + t.Errorf("expected id new-inst-id, got %s", out["id"]) } if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("unmet expectations: %v", err) -- 2.52.0