Alerting: Use require.ElementsMatch in TestEvaluateExecutionResultsNoData

This commit is contained in:
George Robinson 2021-11-16 17:58:48 +00:00 committed by GitHub
parent 11ec1ddd7e
commit 5f5298ad25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,6 @@ package eval
import (
"fmt"
"sort"
"testing"
"time"
@ -321,11 +320,14 @@ func TestEvaluateExecutionResultsNoData(t *testing.T) {
require.Len(t, v, 2)
require.Equal(t, NoData, v[0].State)
require.Equal(t, NoData, v[1].State)
datasourceUIDs := []string{
v[0].Instance["datasource_uid"],
v[1].Instance["datasource_uid"],
datasourceUIDs := make([]string, 0, len(v))
for _, next := range v {
datasourceUID, ok := next.Instance["datasource_uid"]
require.True(t, ok)
require.NotEqual(t, "", datasourceUID)
datasourceUIDs = append(datasourceUIDs, datasourceUID)
}
sort.Strings(datasourceUIDs)
require.Equal(t, []string{"1", "2"}, datasourceUIDs)
require.ElementsMatch(t, []string{"1", "2"}, datasourceUIDs)
})
}