| 1 | package runner |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "gitlab.com/Timfa/bluegit/internal/store" |
| 7 | ) |
| 8 | |
| 9 | func TestShouldRetry(t *testing.T) { |
| 10 | job := store.Job{RetryMax: 2} |
| 11 | if !shouldRetry(job, "script_failure") { |
| 12 | t.Fatal("lege when herhaalt") |
| 13 | } |
| 14 | job.Attempt = 2 |
| 15 | if shouldRetry(job, "script_failure") { |
| 16 | t.Fatal("max bereikt") |
| 17 | } |
| 18 | job.Attempt = 0 |
| 19 | job.RetryWhen = []string{"runner_system_failure", "stuck_or_timeout_failure"} |
| 20 | if shouldRetry(job, "script_failure") { |
| 21 | t.Fatal("script hoort niet") |
| 22 | } |
| 23 | if !shouldRetry(job, "runner_system_failure") || !shouldRetry(job, "job_execution_timeout") { |
| 24 | t.Fatal("systeem en timeout") |
| 25 | } |
| 26 | if safeSegment("build 1/3") != "build_1_3" { |
| 27 | t.Fatal(safeSegment("build 1/3")) |
| 28 | } |
| 29 | } |