influxdb/inmem/scraper_test.go

31 lines
829 B
Go
Raw Normal View History

2018-09-07 15:45:28 +00:00
package inmem
import (
"context"
"testing"
platform "github.com/influxdata/influxdb"
platformtesting "github.com/influxdata/influxdb/testing"
2018-09-07 15:45:28 +00:00
)
func initScraperTargetStoreService(f platformtesting.TargetFields, t *testing.T) (platform.ScraperTargetStoreService, string, func()) {
2018-09-07 15:45:28 +00:00
s := NewService()
s.IDGenerator = f.IDGenerator
ctx := context.Background()
2018-09-07 15:45:28 +00:00
for _, target := range f.Targets {
if err := s.PutTarget(ctx, target); err != nil {
2018-09-07 15:45:28 +00:00
t.Fatalf("failed to populate scraper targets")
}
}
2019-01-18 20:46:37 +00:00
for _, m := range f.UserResourceMappings {
if err := s.PutUserResourceMapping(ctx, m); err != nil {
t.Fatalf("failed to populate user resource mapping")
}
}
return s, OpPrefix, func() {}
2018-09-07 15:45:28 +00:00
}
2019-01-18 20:46:37 +00:00
func TestScraperTargetStoreService(t *testing.T) {
platformtesting.ScraperService(initScraperTargetStoreService, t)
2018-09-07 15:45:28 +00:00
}