2018-09-07 15:45:28 +00:00
|
|
|
package inmem
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
2019-01-08 00:37:16 +00:00
|
|
|
platform "github.com/influxdata/influxdb"
|
|
|
|
platformtesting "github.com/influxdata/influxdb/testing"
|
2018-09-07 15:45:28 +00:00
|
|
|
)
|
|
|
|
|
2018-12-17 14:07:38 +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
|
2018-10-12 01:06:43 +00:00
|
|
|
ctx := context.Background()
|
2018-09-07 15:45:28 +00:00
|
|
|
for _, target := range f.Targets {
|
2018-10-12 01:06:43 +00:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|
2018-12-17 14:07:38 +00:00
|
|
|
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
|
|
|
}
|