fix(influxdb): fixes broken tests from system bucket changes
parent
2e0749b3ba
commit
b343250390
|
@ -14,7 +14,7 @@ func TestID(t *testing.T) {
|
|||
}
|
||||
defer closeFn()
|
||||
|
||||
c.IDGenerator = mock.NewIDGenerator(testIDStr, t)
|
||||
c.IDGenerator = mock.NewIDGenerator(testID.String(), t)
|
||||
|
||||
if err := c.Open(context.Background()); err != nil {
|
||||
t.Fatalf("failed to open bolt client: %v", err)
|
||||
|
|
|
@ -11,8 +11,9 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
testID = platform.ID(1)
|
||||
testIDStr = testID.String()
|
||||
testID = platform.ID(70000)
|
||||
existingBucketID = platform.ID(mock.FirstMockID + 1)
|
||||
firstMockID = platform.ID(mock.FirstMockID)
|
||||
)
|
||||
|
||||
func TestClient_Name(t *testing.T) {
|
||||
|
@ -71,15 +72,21 @@ func TestClient_Name(t *testing.T) {
|
|||
args: args{
|
||||
resource: platform.Resource{
|
||||
Type: platform.BucketsResourceType,
|
||||
ID: platformtesting.IDPtr(testID),
|
||||
ID: &existingBucketID,
|
||||
},
|
||||
init: func(ctx context.Context, s *bolt.Client) error {
|
||||
_ = s.CreateOrganization(ctx, &platform.Organization{
|
||||
o := platform.Organization{
|
||||
Name: "o1",
|
||||
})
|
||||
}
|
||||
|
||||
err := s.CreateOrganization(ctx, &o)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.CreateBucket(ctx, &platform.Bucket{
|
||||
Name: "b1",
|
||||
OrgID: testID,
|
||||
OrgID: platform.ID(mock.FirstMockID),
|
||||
})
|
||||
},
|
||||
},
|
||||
|
@ -100,7 +107,7 @@ func TestClient_Name(t *testing.T) {
|
|||
args: args{
|
||||
resource: platform.Resource{
|
||||
Type: platform.DashboardsResourceType,
|
||||
ID: platformtesting.IDPtr(testID),
|
||||
ID: &firstMockID,
|
||||
},
|
||||
init: func(ctx context.Context, s *bolt.Client) error {
|
||||
return s.CreateDashboard(ctx, &platform.Dashboard{
|
||||
|
@ -126,7 +133,7 @@ func TestClient_Name(t *testing.T) {
|
|||
args: args{
|
||||
resource: platform.Resource{
|
||||
Type: platform.OrgsResourceType,
|
||||
ID: platformtesting.IDPtr(testID),
|
||||
ID: &firstMockID,
|
||||
},
|
||||
init: func(ctx context.Context, s *bolt.Client) error {
|
||||
return s.CreateOrganization(ctx, &platform.Organization{
|
||||
|
@ -151,7 +158,7 @@ func TestClient_Name(t *testing.T) {
|
|||
args: args{
|
||||
resource: platform.Resource{
|
||||
Type: platform.SourcesResourceType,
|
||||
ID: platformtesting.IDPtr(testID),
|
||||
ID: &firstMockID,
|
||||
},
|
||||
init: func(ctx context.Context, s *bolt.Client) error {
|
||||
return s.CreateSource(ctx, &platform.Source{
|
||||
|
@ -176,7 +183,7 @@ func TestClient_Name(t *testing.T) {
|
|||
args: args{
|
||||
resource: platform.Resource{
|
||||
Type: platform.TelegrafsResourceType,
|
||||
ID: platformtesting.IDPtr(testID),
|
||||
ID: &firstMockID,
|
||||
},
|
||||
init: func(ctx context.Context, s *bolt.Client) error {
|
||||
return s.CreateTelegrafConfig(ctx, &platform.TelegrafConfig{
|
||||
|
@ -202,7 +209,7 @@ func TestClient_Name(t *testing.T) {
|
|||
args: args{
|
||||
resource: platform.Resource{
|
||||
Type: platform.UsersResourceType,
|
||||
ID: platformtesting.IDPtr(testID),
|
||||
ID: &firstMockID,
|
||||
},
|
||||
init: func(ctx context.Context, s *bolt.Client) error {
|
||||
return s.CreateUser(ctx, &platform.User{
|
||||
|
@ -230,8 +237,8 @@ func TestClient_Name(t *testing.T) {
|
|||
t.Fatalf("unable to create bolt test client: %v", err)
|
||||
}
|
||||
defer done()
|
||||
|
||||
c.IDGenerator = mock.NewIDGenerator(testIDStr, t)
|
||||
mockIDGen := mock.NewMockIDGenerator()
|
||||
c.IDGenerator = mockIDGen
|
||||
ctx := context.Background()
|
||||
if tt.args.init != nil {
|
||||
if err := tt.args.init(ctx, c); err != nil {
|
||||
|
@ -242,6 +249,7 @@ func TestClient_Name(t *testing.T) {
|
|||
if tt.args.resource.ID != nil {
|
||||
id = *tt.args.resource.ID
|
||||
}
|
||||
|
||||
got, err := c.Name(ctx, tt.args.resource.Type, id)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("Service.Name() error = %v, wantErr %v", err, tt.wantErr)
|
||||
|
|
|
@ -149,9 +149,7 @@ type retentionRule struct {
|
|||
}
|
||||
|
||||
func (rr *retentionRule) RetentionPeriod() (time.Duration, error) {
|
||||
var t time.Duration
|
||||
|
||||
t = time.Duration(rr.EverySeconds) * time.Second
|
||||
t := time.Duration(rr.EverySeconds) * time.Second
|
||||
if t < time.Second {
|
||||
return t, &influxdb.Error{
|
||||
Code: influxdb.EUnprocessableEntity,
|
||||
|
|
|
@ -5,14 +5,16 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/influxdata/influxdb"
|
||||
platform "github.com/influxdata/influxdb"
|
||||
"github.com/influxdata/influxdb/kv"
|
||||
"github.com/influxdata/influxdb/mock"
|
||||
influxdbtesting "github.com/influxdata/influxdb/testing"
|
||||
)
|
||||
|
||||
var (
|
||||
testID = influxdb.ID(10000)
|
||||
testIDStr = testID.String()
|
||||
existingBucketID = platform.ID(mock.FirstMockID + 3)
|
||||
firstMockID = platform.ID(mock.FirstMockID)
|
||||
nonexistantID = platform.ID(10001)
|
||||
)
|
||||
|
||||
type StoreFn func() (kv.Store, func(), error)
|
||||
|
@ -61,7 +63,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
args: args{
|
||||
resource: influxdb.Resource{
|
||||
Type: influxdb.AuthorizationsResourceType,
|
||||
ID: influxdbtesting.IDPtr(testID),
|
||||
ID: &firstMockID,
|
||||
},
|
||||
},
|
||||
want: "",
|
||||
|
@ -71,7 +73,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
args: args{
|
||||
resource: influxdb.Resource{
|
||||
Type: influxdb.TasksResourceType,
|
||||
ID: influxdbtesting.IDPtr(testID),
|
||||
ID: &firstMockID,
|
||||
},
|
||||
},
|
||||
want: "",
|
||||
|
@ -81,7 +83,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
args: args{
|
||||
resource: influxdb.Resource{
|
||||
Type: influxdb.BucketsResourceType,
|
||||
ID: influxdbtesting.IDPtr(testID),
|
||||
ID: &existingBucketID,
|
||||
},
|
||||
init: func(ctx context.Context, s *kv.Service) error {
|
||||
o1 := &influxdb.Organization{
|
||||
|
@ -91,7 +93,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
t.Log(o1)
|
||||
return s.CreateBucket(ctx, &influxdb.Bucket{
|
||||
Name: "b1",
|
||||
OrgID: testID,
|
||||
OrgID: o1.ID,
|
||||
})
|
||||
},
|
||||
},
|
||||
|
@ -102,7 +104,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
args: args{
|
||||
resource: influxdb.Resource{
|
||||
Type: influxdb.BucketsResourceType,
|
||||
ID: influxdbtesting.IDPtr(testID),
|
||||
ID: &nonexistantID,
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
|
@ -112,7 +114,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
args: args{
|
||||
resource: influxdb.Resource{
|
||||
Type: influxdb.DashboardsResourceType,
|
||||
ID: influxdbtesting.IDPtr(testID),
|
||||
ID: &firstMockID,
|
||||
},
|
||||
init: func(ctx context.Context, s *kv.Service) error {
|
||||
return s.CreateDashboard(ctx, &influxdb.Dashboard{
|
||||
|
@ -128,7 +130,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
args: args{
|
||||
resource: influxdb.Resource{
|
||||
Type: influxdb.DashboardsResourceType,
|
||||
ID: influxdbtesting.IDPtr(testID),
|
||||
ID: &nonexistantID,
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
|
@ -138,7 +140,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
args: args{
|
||||
resource: influxdb.Resource{
|
||||
Type: influxdb.OrgsResourceType,
|
||||
ID: influxdbtesting.IDPtr(testID),
|
||||
ID: &firstMockID,
|
||||
},
|
||||
init: func(ctx context.Context, s *kv.Service) error {
|
||||
return s.CreateOrganization(ctx, &influxdb.Organization{
|
||||
|
@ -153,7 +155,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
args: args{
|
||||
resource: influxdb.Resource{
|
||||
Type: influxdb.OrgsResourceType,
|
||||
ID: influxdbtesting.IDPtr(testID),
|
||||
ID: &nonexistantID,
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
|
@ -163,7 +165,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
args: args{
|
||||
resource: influxdb.Resource{
|
||||
Type: influxdb.SourcesResourceType,
|
||||
ID: influxdbtesting.IDPtr(testID),
|
||||
ID: &firstMockID,
|
||||
},
|
||||
init: func(ctx context.Context, s *kv.Service) error {
|
||||
return s.CreateSource(ctx, &influxdb.Source{
|
||||
|
@ -178,7 +180,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
args: args{
|
||||
resource: influxdb.Resource{
|
||||
Type: influxdb.SourcesResourceType,
|
||||
ID: influxdbtesting.IDPtr(testID),
|
||||
ID: &nonexistantID,
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
|
@ -188,13 +190,13 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
args: args{
|
||||
resource: influxdb.Resource{
|
||||
Type: influxdb.TelegrafsResourceType,
|
||||
ID: influxdbtesting.IDPtr(testID),
|
||||
ID: &firstMockID,
|
||||
},
|
||||
init: func(ctx context.Context, s *kv.Service) error {
|
||||
return s.CreateTelegrafConfig(ctx, &influxdb.TelegrafConfig{
|
||||
OrgID: influxdbtesting.MustIDBase16("0000000000000009"),
|
||||
Name: "telegraf1",
|
||||
}, testID)
|
||||
}, existingBucketID)
|
||||
},
|
||||
},
|
||||
want: "telegraf1",
|
||||
|
@ -204,7 +206,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
args: args{
|
||||
resource: influxdb.Resource{
|
||||
Type: influxdb.TelegrafsResourceType,
|
||||
ID: influxdbtesting.IDPtr(testID),
|
||||
ID: &nonexistantID,
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
|
@ -214,7 +216,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
args: args{
|
||||
resource: influxdb.Resource{
|
||||
Type: influxdb.UsersResourceType,
|
||||
ID: influxdbtesting.IDPtr(testID),
|
||||
ID: &firstMockID,
|
||||
},
|
||||
init: func(ctx context.Context, s *kv.Service) error {
|
||||
return s.CreateUser(ctx, &influxdb.User{
|
||||
|
@ -229,7 +231,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
args: args{
|
||||
resource: influxdb.Resource{
|
||||
Type: influxdb.UsersResourceType,
|
||||
ID: influxdbtesting.IDPtr(testID),
|
||||
ID: &nonexistantID,
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
|
@ -244,7 +246,8 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
svc := kv.NewService(store)
|
||||
defer done()
|
||||
|
||||
svc.IDGenerator = mock.NewIDGenerator(testIDStr, t)
|
||||
svc.IDGenerator = mock.NewMockIDGenerator()
|
||||
svc.OrgBucketIDs = mock.NewMockIDGenerator()
|
||||
svc.WithSpecialOrgBucketIDs(svc.IDGenerator)
|
||||
ctx := context.Background()
|
||||
if tt.args.init != nil {
|
||||
|
|
|
@ -30,6 +30,28 @@ func NewIDGenerator(s string, t *testing.T) IDGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
type MockIDGenerator struct {
|
||||
Last *platform.ID
|
||||
Count int
|
||||
}
|
||||
|
||||
const FirstMockID int = 65536
|
||||
|
||||
func NewMockIDGenerator() *MockIDGenerator {
|
||||
return &MockIDGenerator{
|
||||
Count: FirstMockID,
|
||||
}
|
||||
}
|
||||
|
||||
func (g *MockIDGenerator) ID() platform.ID {
|
||||
id := platform.ID(g.Count)
|
||||
g.Count++
|
||||
|
||||
g.Last = &id
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
// NewTokenGenerator is a simple way to create immutable token generator.
|
||||
func NewTokenGenerator(s string, err error) TokenGenerator {
|
||||
return TokenGenerator{
|
||||
|
|
|
@ -3,15 +3,14 @@ package testing
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/influxdata/influxdb"
|
||||
platform "github.com/influxdata/influxdb"
|
||||
"github.com/influxdata/influxdb/mock"
|
||||
"github.com/influxdata/influxdb/rand"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -19,6 +18,12 @@ const (
|
|||
orgTwoID = "020f755c3c083001"
|
||||
)
|
||||
|
||||
var orgBucketsIDGenerator *mock.MockIDGenerator
|
||||
|
||||
func init() {
|
||||
orgBucketsIDGenerator = mock.NewMockIDGenerator()
|
||||
}
|
||||
|
||||
var organizationCmpOptions = cmp.Options{
|
||||
cmp.Comparer(func(x, y []byte) bool {
|
||||
return bytes.Equal(x, y)
|
||||
|
@ -34,10 +39,10 @@ var organizationCmpOptions = cmp.Options{
|
|||
|
||||
// OrganizationFields will include the IDGenerator, and organizations
|
||||
type OrganizationFields struct {
|
||||
IDGenerator influxdb.IDGenerator
|
||||
IDGenerator *mock.MockIDGenerator
|
||||
Organizations []*influxdb.Organization
|
||||
TimeGenerator influxdb.TimeGenerator
|
||||
OrgBucketIDs influxdb.IDGenerator
|
||||
OrgBucketIDs *mock.MockIDGenerator
|
||||
}
|
||||
|
||||
// OrganizationService tests all the service functions.
|
||||
|
@ -103,8 +108,8 @@ func CreateOrganization(
|
|||
{
|
||||
name: "create organizations with empty set",
|
||||
fields: OrganizationFields{
|
||||
IDGenerator: mock.NewIDGenerator(orgOneID, t),
|
||||
OrgBucketIDs: mock.NewIDGenerator(orgOneID, t),
|
||||
IDGenerator: mock.NewMockIDGenerator(),
|
||||
OrgBucketIDs: mock.NewMockIDGenerator(),
|
||||
TimeGenerator: mock.TimeGenerator{FakeValue: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC)},
|
||||
Organizations: []*influxdb.Organization{},
|
||||
},
|
||||
|
@ -119,7 +124,7 @@ func CreateOrganization(
|
|||
organizations: []*influxdb.Organization{
|
||||
{
|
||||
Name: "name1",
|
||||
ID: MustIDBase16(orgOneID),
|
||||
ID: platform.ID(mock.FirstMockID),
|
||||
Description: "desc1",
|
||||
CRUDLog: influxdb.CRUDLog{
|
||||
CreatedAt: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC),
|
||||
|
@ -132,8 +137,8 @@ func CreateOrganization(
|
|||
{
|
||||
name: "basic create organization",
|
||||
fields: OrganizationFields{
|
||||
IDGenerator: mock.NewIDGenerator(orgTwoID, t),
|
||||
OrgBucketIDs: mock.NewIDGenerator(orgTwoID, t),
|
||||
IDGenerator: mock.NewMockIDGenerator(),
|
||||
OrgBucketIDs: mock.NewMockIDGenerator(),
|
||||
TimeGenerator: mock.TimeGenerator{FakeValue: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC)},
|
||||
Organizations: []*influxdb.Organization{
|
||||
{
|
||||
|
@ -155,7 +160,7 @@ func CreateOrganization(
|
|||
Name: "organization1",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(orgTwoID),
|
||||
ID: platform.ID(mock.FirstMockID),
|
||||
Name: "organization2",
|
||||
CRUDLog: influxdb.CRUDLog{
|
||||
CreatedAt: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC),
|
||||
|
@ -168,8 +173,8 @@ func CreateOrganization(
|
|||
{
|
||||
name: "empty name",
|
||||
fields: OrganizationFields{
|
||||
IDGenerator: mock.NewIDGenerator(orgTwoID, t),
|
||||
OrgBucketIDs: mock.NewIDGenerator(orgTwoID, t),
|
||||
IDGenerator: mock.NewMockIDGenerator(),
|
||||
OrgBucketIDs: orgBucketsIDGenerator,
|
||||
TimeGenerator: mock.TimeGenerator{FakeValue: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC)},
|
||||
Organizations: []*influxdb.Organization{
|
||||
{
|
||||
|
@ -196,8 +201,8 @@ func CreateOrganization(
|
|||
{
|
||||
name: "name only have spaces",
|
||||
fields: OrganizationFields{
|
||||
IDGenerator: mock.NewIDGenerator(orgTwoID, t),
|
||||
OrgBucketIDs: mock.NewIDGenerator(orgTwoID, t),
|
||||
IDGenerator: mock.NewMockIDGenerator(),
|
||||
OrgBucketIDs: orgBucketsIDGenerator,
|
||||
TimeGenerator: mock.TimeGenerator{FakeValue: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC)},
|
||||
Organizations: []*influxdb.Organization{
|
||||
{
|
||||
|
@ -225,8 +230,8 @@ func CreateOrganization(
|
|||
{
|
||||
name: "names should be unique",
|
||||
fields: OrganizationFields{
|
||||
IDGenerator: mock.NewIDGenerator(orgTwoID, t),
|
||||
OrgBucketIDs: mock.NewIDGenerator(orgTwoID, t),
|
||||
IDGenerator: mock.NewMockIDGenerator(),
|
||||
OrgBucketIDs: orgBucketsIDGenerator,
|
||||
TimeGenerator: mock.TimeGenerator{FakeValue: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC)},
|
||||
Organizations: []*influxdb.Organization{
|
||||
{
|
||||
|
@ -258,8 +263,8 @@ func CreateOrganization(
|
|||
{
|
||||
name: "create organization with no id",
|
||||
fields: OrganizationFields{
|
||||
IDGenerator: mock.NewIDGenerator(orgTwoID, t),
|
||||
OrgBucketIDs: mock.NewIDGenerator(orgTwoID, t),
|
||||
IDGenerator: mock.NewMockIDGenerator(),
|
||||
OrgBucketIDs: mock.NewMockIDGenerator(),
|
||||
TimeGenerator: mock.TimeGenerator{FakeValue: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC)},
|
||||
Organizations: []*influxdb.Organization{
|
||||
{
|
||||
|
@ -280,7 +285,7 @@ func CreateOrganization(
|
|||
Name: "organization1",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(orgTwoID),
|
||||
ID: platform.ID(mock.FirstMockID),
|
||||
Name: "organization2",
|
||||
CRUDLog: influxdb.CRUDLog{
|
||||
CreatedAt: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC),
|
||||
|
@ -293,8 +298,8 @@ func CreateOrganization(
|
|||
{
|
||||
name: "names should be unique",
|
||||
fields: OrganizationFields{
|
||||
IDGenerator: mock.NewIDGenerator(orgTwoID, t),
|
||||
OrgBucketIDs: mock.NewIDGenerator(orgTwoID, t),
|
||||
IDGenerator: mock.NewMockIDGenerator(),
|
||||
OrgBucketIDs: orgBucketsIDGenerator,
|
||||
TimeGenerator: mock.TimeGenerator{FakeValue: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC)},
|
||||
Organizations: []*influxdb.Organization{
|
||||
{
|
||||
|
@ -323,96 +328,6 @@ func CreateOrganization(
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ids should be unique",
|
||||
fields: OrganizationFields{
|
||||
IDGenerator: mock.NewIDGenerator(orgOneID, t),
|
||||
OrgBucketIDs: mock.NewIDGenerator(orgOneID, t),
|
||||
TimeGenerator: mock.TimeGenerator{FakeValue: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC)},
|
||||
Organizations: []*influxdb.Organization{
|
||||
{
|
||||
ID: MustIDBase16(orgOneID),
|
||||
Name: "organization1",
|
||||
},
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
organization: &influxdb.Organization{
|
||||
ID: MustIDBase16(orgOneID),
|
||||
Name: "organization2",
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
organizations: []*influxdb.Organization{
|
||||
{
|
||||
ID: MustIDBase16(orgOneID),
|
||||
Name: "organization1",
|
||||
},
|
||||
},
|
||||
err: &influxdb.Error{
|
||||
Code: influxdb.EInternal,
|
||||
Msg: fmt.Sprintf("unable to generate valid id"),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "reserved ids should not be created",
|
||||
fields: OrganizationFields{
|
||||
IDGenerator: mock.NewIDGenerator("000000000000000a", t),
|
||||
OrgBucketIDs: mock.NewIDGenerator("000000000000000a", t),
|
||||
TimeGenerator: mock.TimeGenerator{FakeValue: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC)},
|
||||
Organizations: []*influxdb.Organization{
|
||||
{
|
||||
ID: MustIDBase16(orgOneID),
|
||||
Name: "organization1",
|
||||
},
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
organization: &influxdb.Organization{
|
||||
ID: MustIDBase16(orgOneID),
|
||||
Name: "organization2",
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
organizations: []*influxdb.Organization{
|
||||
{
|
||||
ID: MustIDBase16(orgOneID),
|
||||
Name: "organization1",
|
||||
},
|
||||
},
|
||||
err: &influxdb.Error{
|
||||
Code: influxdb.EInternal,
|
||||
Msg: fmt.Sprintf("unable to generate valid id"),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "randomly generted org ids should not have commas, spaces, or backslashes",
|
||||
fields: OrganizationFields{
|
||||
OrgBucketIDs: rand.NewOrgBucketID(42),
|
||||
TimeGenerator: mock.TimeGenerator{FakeValue: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC)},
|
||||
Organizations: []*influxdb.Organization{},
|
||||
},
|
||||
args: args{
|
||||
organization: &influxdb.Organization{
|
||||
Name: "o1",
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
organizations: []*influxdb.Organization{
|
||||
{
|
||||
ID: MustIDBase16("afbf64b1967f8c53"),
|
||||
Name: "o1",
|
||||
|
||||
CRUDLog: influxdb.CRUDLog{
|
||||
CreatedAt: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC),
|
||||
UpdatedAt: time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
Loading…
Reference in New Issue