NGAlert: Fix flaky test (#33415)

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
This commit is contained in:
Ganesh Vernekar
2021-04-27 17:03:22 +05:30
committed by GitHub
parent f5efe97763
commit be1affe0a4

View File

@@ -5,6 +5,7 @@ import (
"errors" "errors"
"io/ioutil" "io/ioutil"
"os" "os"
"sort"
"testing" "testing"
"time" "time"
@@ -284,7 +285,12 @@ func TestPutAlert(t *testing.T) {
// We take the "now" time from one of the UpdatedAt. // We take the "now" time from one of the UpdatedAt.
now := alerts[0].UpdatedAt now := alerts[0].UpdatedAt
require.Equal(t, c.expAlerts(now), alerts) expAlerts := c.expAlerts(now)
sort.Sort(types.AlertSlice(expAlerts))
sort.Sort(types.AlertSlice(alerts))
require.Equal(t, expAlerts, alerts)
}) })
} }
} }