diff --git a/bolt/organizations.go b/bolt/organizations.go index f2b65a615a..7c560267a3 100644 --- a/bolt/organizations.go +++ b/bolt/organizations.go @@ -16,10 +16,14 @@ var _ chronograf.OrganizationsStore = &OrganizationsStore{} // OrganizationsBucket is the bucket where organizations are stored. var OrganizationsBucket = []byte("OrganizationsV1") -// DefaultOrganizationID is the ID of the default organization. -const DefaultOrganizationID uint64 = 0 -const DefaultOrganizationName string = "Default" -const DefaultOrganizationRole string = "member" +const ( + // DefaultOrganizationID is the ID of the default organization. + DefaultOrganizationID uint64 = 0 + // DefaultOrganizationName is the Name of the default organization + DefaultOrganizationName string = "Default" + // DefaultOrganizationRole is the DefaultRole for the Default organization + DefaultOrganizationRole string = "member" +) // OrganizationsStore uses bolt to store and retrieve Organizations type OrganizationsStore struct { diff --git a/bolt/organizations_test.go b/bolt/organizations_test.go index af0c23b9be..4f9b2e7343 100644 --- a/bolt/organizations_test.go +++ b/bolt/organizations_test.go @@ -393,6 +393,44 @@ func TestOrganizationStore_Delete(t *testing.T) { } } +func TestOrganizationStore_DeleteDefaultOrg(t *testing.T) { + type args struct { + ctx context.Context + } + tests := []struct { + name string + args args + wantErr bool + }{ + { + name: "Delete the default organization", + args: args{ + ctx: context.Background(), + }, + wantErr: true, + }, + } + for _, tt := range tests { + client, err := NewTestClient() + if err != nil { + t.Fatal(err) + } + if err := client.Open(context.TODO()); err != nil { + t.Fatal(err) + } + defer client.Close() + s := client.OrganizationsStore + + defaultOrg, err := s.DefaultOrganization(tt.args.ctx) + if err != nil { + t.Fatal(err) + } + if err := s.Delete(tt.args.ctx, defaultOrg); (err != nil) != tt.wantErr { + t.Errorf("%q. OrganizationsStore.Delete() error = %v, wantErr %v", tt.name, err, tt.wantErr) + } + } +} + func TestOrganizationsStore_Add(t *testing.T) { type fields struct { orgs []chronograf.Organization