2018-05-15 21:19:44 +00:00
|
|
|
package bolt_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/influxdata/platform"
|
|
|
|
platformtesting "github.com/influxdata/platform/testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func initBucketService(f platformtesting.BucketFields, t *testing.T) (platform.BucketService, func()) {
|
|
|
|
c, closeFn, err := NewTestClient()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("failed to create new bolt client: %v", err)
|
|
|
|
}
|
|
|
|
c.IDGenerator = f.IDGenerator
|
|
|
|
ctx := context.TODO()
|
2018-05-16 18:59:35 +00:00
|
|
|
for _, o := range f.Organizations {
|
|
|
|
if err := c.PutOrganization(ctx, o); err != nil {
|
|
|
|
t.Fatalf("failed to populate organizations")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, b := range f.Buckets {
|
|
|
|
if err := c.PutBucket(ctx, b); err != nil {
|
2018-05-15 21:19:44 +00:00
|
|
|
t.Fatalf("failed to populate buckets")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return c, func() {
|
|
|
|
defer closeFn()
|
2018-05-16 18:59:35 +00:00
|
|
|
for _, o := range f.Organizations {
|
2018-07-30 14:29:52 +00:00
|
|
|
if err := c.DeleteOrganization(ctx, o.ID); err != nil {
|
2018-05-16 18:59:35 +00:00
|
|
|
t.Logf("failed to remove organization: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, b := range f.Buckets {
|
2018-07-30 14:29:52 +00:00
|
|
|
if err := c.DeleteBucket(ctx, b.ID); err != nil {
|
2018-05-16 18:59:35 +00:00
|
|
|
t.Logf("failed to remove bucket: %v", err)
|
2018-05-15 21:19:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBucketService_CreateBucket(t *testing.T) {
|
|
|
|
platformtesting.CreateBucket(initBucketService, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBucketService_FindBucketByID(t *testing.T) {
|
|
|
|
platformtesting.FindBucketByID(initBucketService, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBucketService_FindBuckets(t *testing.T) {
|
|
|
|
platformtesting.FindBuckets(initBucketService, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBucketService_DeleteBucket(t *testing.T) {
|
|
|
|
platformtesting.DeleteBucket(initBucketService, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBucketService_FindBucket(t *testing.T) {
|
|
|
|
platformtesting.FindBucket(initBucketService, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBucketService_UpdateBucket(t *testing.T) {
|
|
|
|
platformtesting.UpdateBucket(initBucketService, t)
|
|
|
|
}
|