package processing import "testing" func TestIsProcessableJobStatus(t *testing.T) { t.Parallel() cases := []struct { in string want bool }{ {"pending", true}, {"running", true}, {"PENDING", true}, {" completed ", false}, {"cancelled", false}, {"canceled", false}, {"failed", false}, {"", false}, {"queued", false}, } for _, tc := range cases { if got := IsProcessableJobStatus(tc.in); got != tc.want { t.Fatalf("IsProcessableJobStatus(%q)=%v want %v", tc.in, got, tc.want) } } } func TestFormatParseJobUserError(t *testing.T) { t.Parallel() raw := FormatJobUserError(JobErrAllFailedKey, 3) want := "processing.job.error.all_failed|count=3" if raw != want { t.Fatalf("FormatJobUserError=%q want %q", raw, want) } key, count, ok := ParseJobUserError(raw) if !ok || key != JobErrAllFailedKey || count != 3 { t.Fatalf("ParseJobUserError got key=%q count=%d ok=%v", key, count, ok) } partial := FormatJobUserError(JobErrPartialFailedKey, 1) key, count, ok = ParseJobUserError(partial) if !ok || key != JobErrPartialFailedKey || count != 1 { t.Fatalf("partial parse key=%q count=%d ok=%v", key, count, ok) } if _, _, ok := ParseJobUserError("legacy english failure"); ok { t.Fatal("legacy prose must not parse as keyed error") } if _, _, ok := ParseJobUserError(""); ok { t.Fatal("empty must not parse") } }