package dcache // P6 owner review: the sweep never removes a live job. import ( "testing" "time" ) func TestSweepSparesLiveJobs(t *testing.T) { db := newBatchDB(t) for _, st := range []string{"queued", "running", "done"} { if err := db.CreateBatchJob(BatchJob{ID: st, Caller: "a", CallerClass: ClassFleet, IDemKey: st, Status: st, TargetsTotal: 1, CreatedAt: 1, Lease: 1}); err != nil { t.Fatal(err) } } if n := db.SweepBatch(1_000_000, time.Hour); n != 1 { t.Fatalf("swept %d, want only the done job", n) } for _, id := range []string{"queued", "running"} { if _, ok := db.BatchJob(id); !ok { t.Fatalf("live job %s was swept", id) } } }