Add CalcSilenceState Test (#1085)

This commit is contained in:
Jose Donizetti 2017-11-11 12:13:12 -02:00 committed by stuart nelson
parent 33644a85df
commit cf85bd84f2
1 changed files with 21 additions and 0 deletions

View File

@ -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)
}