Skip to content

Commit

Permalink
Test history.SlaDowntimeEndTime#Value()
Browse files Browse the repository at this point in the history
  • Loading branch information
Al2Klimov committed Sep 5, 2024
1 parent 1679d00 commit 72283bc
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pkg/icingadb/v1/history/downtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,39 @@ func TestDowntimeEventTime_Value(t *testing.T) {
})
}
}

func TestSlaDowntimeEndTime_Value(t *testing.T) {
cancel := types.UnixMilli(time.Unix(42, 240000000))
end := types.UnixMilli(time.Unix(1337, 733100000))

f := types.Bool{Bool: false, Valid: true}
T := types.Bool{Bool: true, Valid: true}

subtests := []struct {
name string
cancelled types.Bool
cancelTime types.UnixMilli
endTime types.UnixMilli
output driver.Value
}{
{name: "nil", cancelTime: cancel, endTime: end, output: int64(1337733)},
{name: "invalid", cancelled: types.Bool{Bool: true}, cancelTime: cancel, endTime: end, output: int64(1337733)},
{name: "false", cancelled: f, cancelTime: cancel, endTime: end, output: int64(1337733)},
{name: "true", cancelled: T, cancelTime: cancel, endTime: end, output: int64(42240)},
{name: "false-nil", cancelled: f, cancelTime: cancel},
{name: "true-nil", cancelled: T, endTime: end},
}

for _, st := range subtests {
t.Run(st.name, func(t *testing.T) {
v, err := (SlaDowntimeEndTime{History: &SlaHistoryDowntime{
HasBeenCancelled: st.cancelled,
CancelTime: st.cancelTime,
EndTime: st.endTime,
}}).Value()

require.NoError(t, err)
require.Equal(t, st.output, v)
})
}
}

0 comments on commit 72283bc

Please sign in to comment.