Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
worldtiki committed Apr 6, 2024
1 parent 03a90f0 commit 74bd625
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions internal/pkg/calendar/calendar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,24 @@ func TestIsWeekDay(t *testing.T) {
assert.False(t, isWeekday(monday.Add(time.Hour*24*6)))
}

func TestShouldParseMtbf(t *testing.T) {
duration, _ := ParseMtbf("2d")
assert.Equal(t, time.Hour*24*2, duration)

duration, _ = ParseMtbf("2h")
assert.Equal(t, time.Hour*2, duration)

duration, _ = ParseMtbf("2m")
assert.Equal(t, time.Minute*2, duration)

// Special case where we don't have a time unit and we assume days
duration, _ = ParseMtbf("2")
assert.Equal(t, duration, time.Hour*24*2)
}

func TestParseMtbfShouldNotAllowDurationLessThanAMinute(t *testing.T) {
_, err := ParseMtbf("30s")
assert.NotNil(t, err)
}

// FIXME: add more tests

0 comments on commit 74bd625

Please sign in to comment.