forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice_test.go
45 lines (39 loc) · 1.12 KB
/
service_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package dbrp_test
import (
"context"
"fmt"
"testing"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/dbrp"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/mock"
itesting "github.com/influxdata/influxdb/v2/testing"
)
func initDBRPMappingService(f itesting.DBRPMappingFields, t *testing.T) (influxdb.DBRPMappingService, func()) {
s, closeStore := itesting.NewTestBoltStore(t)
if f.BucketSvc == nil {
f.BucketSvc = &mock.BucketService{
FindBucketByIDFn: func(ctx context.Context, id platform.ID) (*influxdb.Bucket, error) {
// always find a bucket.
return &influxdb.Bucket{
ID: id,
Name: fmt.Sprintf("bucket-%v", id),
}, nil
},
}
}
svc := dbrp.NewService(context.Background(), f.BucketSvc, s)
if err := f.Populate(context.Background(), svc); err != nil {
t.Fatal(err)
}
return svc, func() {
if err := itesting.CleanupDBRPMappingsV2(context.Background(), svc); err != nil {
t.Error(err)
}
closeStore()
}
}
func TestBoltDBRPMappingService(t *testing.T) {
t.Parallel()
itesting.DBRPMappingService(initDBRPMappingService, t)
}