From 66da177fe9044e4949a9420a80ef170763142577 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 14 Apr 2020 13:31:23 +0300 Subject: [PATCH] lib/promscrape: reset ScrapeWork.ID in tests --- lib/promscrape/config_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/promscrape/config_test.go b/lib/promscrape/config_test.go index b4bef5eb1b..f7612146d9 100644 --- a/lib/promscrape/config_test.go +++ b/lib/promscrape/config_test.go @@ -373,6 +373,12 @@ scrape_configs: `) } +func resetScrapeWorkIDs(sws []ScrapeWork) { + for i := range sws { + sws[i].ID = 0 + } +} + func TestGetFileSDScrapeWorkSuccess(t *testing.T) { f := func(data string, expectedSws []ScrapeWork) { t.Helper() @@ -380,6 +386,7 @@ func TestGetFileSDScrapeWorkSuccess(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %s", err) } + resetScrapeWorkIDs(sws) if !reflect.DeepEqual(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 { t.Fatalf("unexpected error: %s", err) } + resetScrapeWorkIDs(sws) if !reflect.DeepEqual(sws, expectedSws) { t.Fatalf("unexpected scrapeWork; got\n%v\nwant\n%v", sws, expectedSws) }