INNER CODE UNIT · Go
TestParseMtbfInvalid
asobti/kube-monkey · internal/pkg/calendar/calendar_test.go:42
func TestParseMtbfInvalid(t *testing.T) {
// Seconds are deliberately not a unit: a minute is as often as kube-monkey
// is willing to kill
for _, value := range []string{"", " ", "0", "0h", "-1", "1.5h", "30s", "1h30m", "3D", "day", "1 d", "3dd", "999999999999999999999d"} {
_, err := ParseMtbf(value)
assert.Error(t, err, value)
}
}
func TestKillTimesInRangeCount(t *testing.T) {
loc := time.UTC
// Before the range opens, so the whole 6 hour range is still available
now := time.Date(2024, 3, 12, 8, 0, 0, 0, loc)
// A victim dies 24h/mtbf times a day, whatever the length of the range
for mtbf, expected := range map[time.Duration]int{
24 * time.Hour: 1,