carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package moves
2
3import "testing"
4
5func TestAttemptsFor(t *testing.T) {
6 for _, c := range []struct {
7 kind string
8 admitted int
9 want int
10 }{
11 {"landing", 2, 2},
12 {"landing", 7, 3},
13 {"landing", 3, 3},
14 {"landing", 1, 1},
15 {"landing", 0, 0},
16 {"landing", -4, 0},
17 {"recovery", 0, 9},
18 {"recovery", 2, 9},
19 {"recovery", 7, 9},
20 {"serving", 3, 0},
21 {"", 3, 0},
22 } {
23 if got := AttemptsFor(c.kind, c.admitted); got != c.want {
24 t.Errorf("AttemptsFor(%q, %d) = %d, want %d", c.kind, c.admitted, got, c.want)
25 }
26 }
27 if ProbeAttemptsMax != 3 || RecoveryAttempts != 9 {
28 t.Fatal("the attempt ceilings are the spec's: 3 for a landing, 9 for a recovery")
29 }
30}
31