From 5cdb720122a2122adee02121d3ad700cacb0a58d Mon Sep 17 00:00:00 2001 From: BaaRai <130491490+BaaRai@users.noreply.github.com> Date: Sat, 14 Nov 2026 15:44:52 +0100 Subject: [PATCH] test(server): stop leaked fixtures from polluting later tests TestMgmtAPI never closed its manager, so the notifier and task-archive workers started by New(context.Background()) kept claiming other tests digest batches and archive jobs. TestTaskOutcomeCard left a skill_usage miss row behind (the table has no foreign keys), which outranked TestSkillGapsReport fixture from the fourth -count iteration on. --- server/mgmt_test.go | 4 ++++ server/task_outcome_test.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/server/mgmt_test.go b/server/mgmt_test.go index d58765b..76c3428 100644 --- a/server/mgmt_test.go +++ b/server/mgmt_test.go @@ -18,6 +18,10 @@ func TestMgmtAPI(t *testing.T) { if m.pg == nil { t.Skip("postgres unavailable — skipping management API test") } + // New starts the notifier and task-archive workers on context.Background(); + // closing the pool stops them from claiming later tests' digest batches + // and archive jobs. + defer m.Close() td := t.TempDir() s := New(context.Background(), m, td, td, td) h := s.Handler() diff --git a/server/task_outcome_test.go b/server/task_outcome_test.go index 4ffaa51..833294b 100644 --- a/server/task_outcome_test.go +++ b/server/task_outcome_test.go @@ -23,6 +23,9 @@ func TestTaskOutcomeCard(t *testing.T) { } taskID, _ := strconv.ParseInt(task.ID, 10, 64) defer func() { _ = m.pg.DeleteTask(taskID) }() + // skill_usage has no foreign keys, so DeleteTask leaves these rows behind, + // and their misses would outrank TestSkillGapsReport's fixture in later runs. + defer func() { _, _ = m.pg.Exec(`DELETE FROM skill_usage WHERE task_id=$1`, taskID) }() if _, err := m.pg.Exec(` INSERT INTO findings(task_id,vulnclass,name,severity,status) VALUES