package moves import "testing" func TestAttemptsFor(t *testing.T) { for _, c := range []struct { kind string admitted int want int }{ {"landing", 2, 2}, {"landing", 7, 3}, {"landing", 3, 3}, {"landing", 1, 1}, {"landing", 0, 0}, {"landing", -4, 0}, {"recovery", 0, 9}, {"recovery", 2, 9}, {"recovery", 7, 9}, {"serving", 3, 0}, {"", 3, 0}, } { if got := AttemptsFor(c.kind, c.admitted); got != c.want { t.Errorf("AttemptsFor(%q, %d) = %d, want %d", c.kind, c.admitted, got, c.want) } } if ProbeAttemptsMax != 3 || RecoveryAttempts != 9 { t.Fatal("the attempt ceilings are the spec's: 3 for a landing, 9 for a recovery") } }