-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improvements on org management (#546)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
- Loading branch information
Showing
31 changed files
with
654 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// Copyright 2023 The Chainloop Authors. | ||
// Copyright 2024 The Chainloop Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
|
@@ -99,22 +99,16 @@ func (s *membershipIntegrationTestSuite) TestCreateMembership() { | |
user, err := s.User.FindOrCreateByEmail(ctx, "[email protected]") | ||
assert.NoError(err) | ||
|
||
s.T().Run("Create default", func(t *testing.T) { | ||
s.T().Run("Create current", func(t *testing.T) { | ||
org, err := s.Organization.CreateWithRandomName(ctx) | ||
assert.NoError(err) | ||
|
||
m, err := s.Membership.Create(ctx, org.ID, user.ID, true) | ||
assert.NoError(err) | ||
assert.Equal(true, m.Current, "Membership should be current") | ||
|
||
wantUserID, err := uuid.Parse(user.ID) | ||
assert.NoError(err) | ||
assert.Equal(wantUserID, m.UserID, "User ID") | ||
|
||
wantORGID, err := uuid.Parse(org.ID) | ||
assert.NoError(err) | ||
assert.Equal(wantORGID, m.OrganizationID, "Organization ID") | ||
|
||
assert.Equal(user.ID, m.UserID.String(), "User ID") | ||
assert.Equal(org.ID, m.OrganizationID.String(), "Organization ID") | ||
assert.EqualValues(org, m.Org, "Embedded organization") | ||
}) | ||
|
||
|
@@ -124,7 +118,26 @@ func (s *membershipIntegrationTestSuite) TestCreateMembership() { | |
|
||
m, err := s.Membership.Create(ctx, org.ID, user.ID, false) | ||
assert.NoError(err) | ||
assert.Equal(false, m.Current, "Membership should be current") | ||
assert.Equal(false, m.Current, "Membership should not be current") | ||
}) | ||
|
||
s.T().Run("current override", func(t *testing.T) { | ||
org, err := s.Organization.CreateWithRandomName(ctx) | ||
assert.NoError(err) | ||
org2, err := s.Organization.CreateWithRandomName(ctx) | ||
assert.NoError(err) | ||
|
||
m, err := s.Membership.Create(ctx, org.ID, user.ID, true) | ||
assert.NoError(err) | ||
s.True(m.Current) | ||
// Creating a new one will override the current status of the previous one | ||
m, err = s.Membership.Create(ctx, org2.ID, user.ID, true) | ||
assert.NoError(err) | ||
s.True(m.Current) | ||
|
||
m, err = s.Membership.FindByOrgAndUser(ctx, org.ID, user.ID) | ||
assert.NoError(err) | ||
s.False(m.Current) | ||
}) | ||
|
||
s.T().Run("Invalid ORG", func(t *testing.T) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.