This commit is contained in:
greeneclipse committed 2026-10-20 17:28:06 +02:00
1 parent c83347b9a5
commit fd83a7c523
2 files changed
+27 -3

No files matched your search

@@ -86,14 +86,15 @@ func TestRetryJobResetsCompletedJobForFullRerun(t *testing.T) {
firstStep = progress[0].Step
}
selectedOutputs := []string{"title", "seo_meta"}
var jobID uuid.UUID
err = pg.QueryRow(ctx, `
INSERT INTO processing_jobs (
company_id, user_id, status, total_products, processed_products,
processing_type, current_step, step_progress, started_at, completed_at
) VALUES ($1, $2, 'completed', $3, $3, 'full', $4, $5::jsonb, now(), now())
processing_type, processing_types, current_step, step_progress, started_at, completed_at
) VALUES ($1, $2, 'completed', $3, $3, 'full', $4, $5, $6::jsonb, now(), now())
RETURNING id`,
companyID, userID, len(rawIDs), firstStep, progressJSON,
companyID, userID, len(rawIDs), firstStep, selectedOutputs, progressJSON,
).Scan(&jobID)
if err != nil {
t.Fatal(err)
@@ -131,6 +132,21 @@ func TestRetryJobResetsCompletedJobForFullRerun(t *testing.T) {
t.Fatalf("completed_at should be reset, got %v", *job.CompletedAt)
}
// Retrying must preserve the saved processing_types; credit gates and the
// worker both need the original output selections, not legacy defaults.
var persistedOutputs []string
if err := pg.QueryRow(ctx, `SELECT processing_types FROM processing_jobs WHERE id = $1`, jobID).Scan(&persistedOutputs); err != nil {
t.Fatal(err)
}
if len(persistedOutputs) != len(selectedOutputs) {
t.Fatalf("processing_types=%v want %v", persistedOutputs, selectedOutputs)
}
for i := range selectedOutputs {
if persistedOutputs[i] != selectedOutputs[i] {
t.Fatalf("processing_types=%v want %v", persistedOutputs, selectedOutputs)
}
}
var pendingCount, processedCount int
err = pg.QueryRow(ctx, `
SELECT