package main import ( "testing" "time" ) func TestBackoff_Schedule(t *testing.T) { cases := []struct { attempt int want time.Duration }{ {1, 30 * time.Second}, {2, 2 * time.Minute}, {3, 10 * time.Minute}, {4, 1 * time.Hour}, {5, 1 * time.Hour}, {99, 1 * time.Hour}, } for _, c := range cases { got := Backoff(c.attempt) if got != c.want { t.Errorf("Backoff(%d) = %s, want %s", c.attempt, got, c.want) } } }