Add CalcSilenceState Test (#1085)
This commit is contained in:
parent
33644a85df
commit
cf85bd84f2
|
@ -19,6 +19,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestAlertMerge(t *testing.T) {
|
||||
|
@ -61,3 +62,23 @@ func TestAlertMerge(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCalcSilenceState(t *testing.T) {
|
||||
|
||||
var (
|
||||
pastStartTime = time.Now()
|
||||
pastEndTime = time.Now()
|
||||
|
||||
futureStartTime = time.Now().Add(time.Hour)
|
||||
futureEndTime = time.Now().Add(time.Hour)
|
||||
)
|
||||
|
||||
expected := CalcSilenceState(futureStartTime, futureEndTime)
|
||||
require.Equal(t, SilenceStatePending, expected)
|
||||
|
||||
expected = CalcSilenceState(pastStartTime, futureEndTime)
|
||||
require.Equal(t, SilenceStateActive, expected)
|
||||
|
||||
expected = CalcSilenceState(pastStartTime, pastEndTime)
|
||||
require.Equal(t, SilenceStateExpired, expected)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue