Compare commits

...
12 changed files with 34 additions and 12 deletions
+2 -2
View File
@@ -127,7 +127,7 @@ func TestIngestScanOutputJSONPG(t *testing.T) {
if err != nil {
t.Fatal(err)
}
const assetsWhere = `domain LIKE '%scan-ingest.example.com' OR url LIKE '%scan-ingest.example.com%'`
const assetsWhere = `ip IN ('198.51.100.77','2001:db8::77') OR domain IN ('198.51.100.77','2001:db8::77','example.com') OR domain LIKE '%scan-ingest.example.com' OR url LIKE '%scan-ingest.example.com%'`
t.Cleanup(func() {
_ = d.DeleteTask(task.ID)
_, _ = d.Exec(`DELETE FROM assets WHERE ` + assetsWhere)
@@ -210,7 +210,7 @@ func TestIngestScanOutputUserinfoPG(t *testing.T) {
if err != nil {
t.Fatal(err)
}
const assetsWhere = `domain LIKE '%scan-ingest.example.com' OR url LIKE '%scan-ingest.example.com%'`
const assetsWhere = `ip IN ('198.51.100.77','2001:db8::77') OR domain IN ('198.51.100.77','2001:db8::77','example.com') OR domain LIKE '%scan-ingest.example.com' OR url LIKE '%scan-ingest.example.com%'`
t.Cleanup(func() {
_ = d.DeleteTask(task.ID)
_, _ = d.Exec(`DELETE FROM assets WHERE ` + assetsWhere)
+2 -2
View File
@@ -22,7 +22,7 @@ func TestFlushActivityOutboxReplaysOnce(t *testing.T) {
if err != nil {
SkipPGUnavailable(t, err)
}
defer d.Close()
t.Cleanup(func() { _ = d.Close() })
expID, err := d.CreateExploration("outbox", "replay")
if err != nil {
t.Fatal(err)
@@ -65,7 +65,7 @@ func TestFlushActivityOutboxDropsStuckRow(t *testing.T) {
if err != nil {
SkipPGUnavailable(t, err)
}
defer d.Close()
t.Cleanup(func() { _ = d.Close() })
const missing = int64(9_000_000_000_001)
t.Cleanup(func() { _, _ = d.Exec(`DELETE FROM activity_outbox WHERE exploration_id=$1`, missing) })
es := d.Exploration(missing)
+1 -1
View File
@@ -13,7 +13,7 @@ func TestTaskLLMSpendCountsJudgeNotChat(t *testing.T) {
if err != nil {
SkipPGUnavailable(t, err)
}
defer d.Close()
t.Cleanup(func() { _ = d.Close() })
taskID := fmt.Sprintf("spend-%d", time.Now().UnixNano())
t.Cleanup(func() {
+3
View File
@@ -73,6 +73,9 @@ func TestCoreTaskLifecyclePG(t *testing.T) {
if id == "" || expID == 0 {
t.Fatalf("bad task payload: %v", out)
}
defer func() {
_, _ = m.pg.Exec(`DELETE FROM assets WHERE type = 'ip' AND ip = '127.0.0.1'`)
}()
// the exploration owns goal node(s) — goal seeding is async, poll briefly
var goals []*db.Node
+1
View File
@@ -282,6 +282,7 @@ func TestFindingTrafficArchiveV3RoundTripAndRetry(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer s.m.pg.DeleteFinding(shared.FindingID)
if _, err = s.m.traffic.DeleteHost("evidence.local"); err != nil {
t.Fatal(err)
}
+5 -1
View File
@@ -286,15 +286,19 @@ func TestDeepenAdmissionFailureDiscardsFollowUpIntent(t *testing.T) {
t.Fatal(err)
}
taskID, _ := strconv.ParseInt(task.ID, 10, 64)
var findingID int64
defer func() {
_, _ = m.pg.Exec(`UPDATE tasks SET deleted_at=NULL WHERE id=$1`, taskID)
if findingID > 0 {
_, _ = m.pg.DeleteFinding(findingID)
}
_, _ = m.DeleteTask(task.ID, DeleteTaskOptions{})
}()
findingNodeID, err := task.Store.AddNode(db.KindFinding, map[string]any{"summary": "source"}, 5, "confirmed", "worker", nil)
if err != nil {
t.Fatal(err)
}
findingID, err := m.pg.AddFinding(taskID, findingNodeID, "test", "source", db.SeverityHigh, "source", "", "worker", nil)
findingID, err = m.pg.AddFinding(taskID, findingNodeID, "test", "source", db.SeverityHigh, "source", "", "worker", nil)
if err != nil {
t.Fatal(err)
}
+1
View File
@@ -74,6 +74,7 @@ func TestRecorderPersistsRawWireBodies(t *testing.T) {
if _, err := pg.Exec(`DELETE FROM llm_records WHERE session_id = $1`, session); err != nil {
t.Logf("cleanup: %v", err)
}
_, _ = pg.Exec(`DELETE FROM llm_usage WHERE task_id = '999999' AND profile_name = 'raw-test-profile'`)
}()
ctx := transcript.WithSessionID(context.Background(), session)
+1
View File
@@ -83,6 +83,7 @@ func (g *gateServer) cleanupTask(t *testing.T, id string) {
_ = g.m.pg.DeleteTask(n)
_, _ = g.m.pg.Exec(`DELETE FROM target_pins WHERE task_id=$1`, n)
_, _ = g.m.pg.Exec(`DELETE FROM intercept_pending WHERE task_id=$1`, id)
_, _ = g.m.pg.Exec(`DELETE FROM assets WHERE type = 'ip' AND ip = '127.0.0.1'`)
})
}
+8 -2
View File
@@ -49,8 +49,14 @@ func TestTaskCredentialsFlow(t *testing.T) {
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = s.m.pg.DeleteTask(id) })
t.Cleanup(func() { s.m.PG().Exec(`DELETE FROM tasks WHERE id=$1`, id) })
t.Cleanup(func() {
_ = s.m.pg.DeleteTask(id)
// The first POST with an invalid credential entry returns 400 after
// creating a task/exploration row; remove any remaining fixture rows.
_, _ = s.m.PG().Exec(`DELETE FROM tasks WHERE description = 'credential flow test'`)
_, _ = s.m.PG().Exec(`DELETE FROM explorations WHERE description = 'credential flow test'`)
_, _ = s.m.PG().Exec(`DELETE FROM assets WHERE type = 'ip' AND ip = '127.0.0.1'`)
})
// List: both rows, user source, order stable.
resp = request("GET", fmt.Sprintf("/api/tasks/%s/credentials", created.ID), "")
+1 -1
View File
@@ -21,7 +21,7 @@ func TestReviveClearsBudgetEndReason(t *testing.T) {
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { pg.Exec(`DELETE FROM tasks WHERE id=$1`, id) })
t.Cleanup(func() { _ = pg.DeleteTask(id) })
endReason := func() string {
t.Helper()
var r string
+8 -2
View File
@@ -75,7 +75,10 @@ func TestRotationConcurrentProvidersAndPrecedence(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer m.DeleteTask(task.ID, DeleteTaskOptions{})
defer func() {
_, _ = m.pg.Exec(`DELETE FROM llm_usage WHERE task_id = $1`, task.ID)
_, _ = m.DeleteTask(task.ID, DeleteTaskOptions{})
}()
s := &Server{m: m, provByProfile: map[int64]*provEntry{}}
runtime := &taskLLMRuntime{s: s, taskID: task.ID, agentKey: "worker"}
done := make(chan error, 3)
@@ -343,7 +346,10 @@ func TestRunIntentRotatesPinnedProfileWithCachedExecCtx(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer m.DeleteTask(task.ID, DeleteTaskOptions{})
defer func() {
_, _ = m.pg.Exec(`DELETE FROM llm_usage WHERE task_id = $1`, task.ID)
_, _ = m.DeleteTask(task.ID, DeleteTaskOptions{})
}()
e := NewEngine(m)
// Warm the per-task cached execCtx before any worker intent runs.
+1 -1
View File
@@ -24,7 +24,7 @@ func TestPauseShiftsTaskDeadlineOnResume(t *testing.T) {
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { pg.Exec(`DELETE FROM tasks WHERE id=$1`, id) })
t.Cleanup(func() { _ = pg.DeleteTask(id) })
// A running task with a stamped deadline (first_run_at + 1h budget).
if _, err := m.StampTaskFirstRun(task.ID); err != nil {