mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 13:09:22 -06:00
d4ae10ecc6
Move unrelated functions out of fetcher
26 lines
832 B
Go
26 lines
832 B
Go
package schedule
|
|
|
|
import (
|
|
"testing"
|
|
|
|
models "github.com/grafana/grafana/pkg/services/ngalert/models"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestHashUIDs(t *testing.T) {
|
|
r := []*models.AlertRule{{UID: "foo"}, {UID: "bar"}}
|
|
assert.Equal(t, uint64(0xade76f55c76a1c48), hashUIDs(r))
|
|
// expect the same hash irrespective of order
|
|
r = []*models.AlertRule{{UID: "bar"}, {UID: "foo"}}
|
|
assert.Equal(t, uint64(0xade76f55c76a1c48), hashUIDs(r))
|
|
// expect a different hash
|
|
r = []*models.AlertRule{{UID: "bar"}}
|
|
assert.Equal(t, uint64(0xd8d9a5186bad3880), hashUIDs(r))
|
|
// slice with no items
|
|
r = []*models.AlertRule{}
|
|
assert.Equal(t, uint64(0xcbf29ce484222325), hashUIDs(r))
|
|
// a different slice with no items should have the same hash
|
|
r = []*models.AlertRule{}
|
|
assert.Equal(t, uint64(0xcbf29ce484222325), hashUIDs(r))
|
|
}
|