From 5ade4def023ea9c33e5fb366fb7f3782cb0c6395 Mon Sep 17 00:00:00 2001 From: Marc Tuduri Date: Thu, 5 Oct 2023 14:15:12 +0200 Subject: [PATCH] Fix tests --- collector/info_schema_processlist_test.go | 8 ++++++-- collector/perf_schema_memory_events_test.go | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/collector/info_schema_processlist_test.go b/collector/info_schema_processlist_test.go index 6bcd0108..c4d37ae9 100644 --- a/collector/info_schema_processlist_test.go +++ b/collector/info_schema_processlist_test.go @@ -27,7 +27,11 @@ import ( ) func TestScrapeProcesslist(t *testing.T) { - _, err := kingpin.CommandLine.Parse([]string{ + scraper := ScrapeProcesslist{} + app := kingpin.New("TestScrapeProcesslist", "") + scraper.RegisterFlags(app) + + _, err := app.Parse([]string{ "--collect.info_schema.processlist.processes_by_user", "--collect.info_schema.processlist.processes_by_host", }) @@ -56,7 +60,7 @@ func TestScrapeProcesslist(t *testing.T) { ch := make(chan prometheus.Metric) go func() { - if err = (ScrapeProcesslist{}).Scrape(context.Background(), db, ch, log.NewNopLogger()); err != nil { + if err = scraper.Scrape(context.Background(), db, ch, log.NewNopLogger()); err != nil { t.Errorf("error calling function on test: %s", err) } close(ch) diff --git a/collector/perf_schema_memory_events_test.go b/collector/perf_schema_memory_events_test.go index 1baa0ead..6b0ea5e5 100644 --- a/collector/perf_schema_memory_events_test.go +++ b/collector/perf_schema_memory_events_test.go @@ -27,7 +27,11 @@ import ( ) func TestScrapePerfMemoryEvents(t *testing.T) { - _, err := kingpin.CommandLine.Parse([]string{}) + scraper := ScrapePerfMemoryEvents{} + + app := kingpin.New("TestScrapePerfMemoryEvents", "") + scraper.RegisterFlags(app) + _, err := app.Parse([]string{}) if err != nil { t.Fatal(err) } @@ -54,7 +58,7 @@ func TestScrapePerfMemoryEvents(t *testing.T) { ch := make(chan prometheus.Metric) go func() { - if err = (ScrapePerfMemoryEvents{}).Scrape(context.Background(), db, ch, log.NewNopLogger()); err != nil { + if err = scraper.Scrape(context.Background(), db, ch, log.NewNopLogger()); err != nil { panic(fmt.Sprintf("error calling function on test: %s", err)) } close(ch)