lib/promscrape: reset ScrapeWork.ID in tests

This commit is contained in:
Aliaksandr Valialkin 2020-04-14 13:31:23 +03:00
parent 88366cad15
commit 66da177fe9

View File

@ -373,6 +373,12 @@ scrape_configs:
`) `)
} }
func resetScrapeWorkIDs(sws []ScrapeWork) {
for i := range sws {
sws[i].ID = 0
}
}
func TestGetFileSDScrapeWorkSuccess(t *testing.T) { func TestGetFileSDScrapeWorkSuccess(t *testing.T) {
f := func(data string, expectedSws []ScrapeWork) { f := func(data string, expectedSws []ScrapeWork) {
t.Helper() t.Helper()
@ -380,6 +386,7 @@ func TestGetFileSDScrapeWorkSuccess(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("unexpected error: %s", err) t.Fatalf("unexpected error: %s", err)
} }
resetScrapeWorkIDs(sws)
if !reflect.DeepEqual(sws, expectedSws) { if !reflect.DeepEqual(sws, expectedSws) {
t.Fatalf("unexpected scrapeWork; got\n%v\nwant\n%v", sws, expectedSws) t.Fatalf("unexpected scrapeWork; got\n%v\nwant\n%v", sws, expectedSws)
} }
@ -509,6 +516,7 @@ func TestGetStaticScrapeWorkSuccess(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("unexpected error: %s", err) t.Fatalf("unexpected error: %s", err)
} }
resetScrapeWorkIDs(sws)
if !reflect.DeepEqual(sws, expectedSws) { if !reflect.DeepEqual(sws, expectedSws) {
t.Fatalf("unexpected scrapeWork; got\n%v\nwant\n%v", sws, expectedSws) t.Fatalf("unexpected scrapeWork; got\n%v\nwant\n%v", sws, expectedSws)
} }