influxdb/bolt/label_test.go

37 lines
861 B
Go
Raw Normal View History

package bolt_test
import (
"context"
"testing"
"github.com/influxdata/platform"
2018-12-18 07:59:04 +00:00
"github.com/influxdata/platform/bolt"
platformtesting "github.com/influxdata/platform/testing"
)
2018-12-18 07:59:04 +00:00
func initLabelService(f platformtesting.LabelFields, t *testing.T) (platform.LabelService, string, func()) {
c, closeFn, err := NewTestClient()
if err != nil {
t.Fatalf("failed to create new bolt client: %v", err)
}
ctx := context.Background()
for _, l := range f.Labels {
if err := c.CreateLabel(ctx, l); err != nil {
t.Fatalf("failed to populate labels")
}
}
2018-12-18 07:59:04 +00:00
return c, bolt.OpPrefix, func() {
defer closeFn()
for _, l := range f.Labels {
if err := c.DeleteLabel(ctx, *l); err != nil {
t.Logf("failed to remove label: %v", err)
}
}
}
}
func TestLabelService_LabelService(t *testing.T) {
platformtesting.LabelService(initLabelService, t)
}