Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user