Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marctc committed Oct 5, 2023
1 parent 9fe3bad commit 5ade4de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions collector/info_schema_processlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions collector/perf_schema_memory_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
Expand Down

0 comments on commit 5ade4de

Please sign in to comment.