-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix lint and test errors, simplify interfaces
- Loading branch information
1 parent
cde854a
commit e10fca5
Showing
9 changed files
with
57 additions
and
53 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
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.
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 |
---|---|---|
|
@@ -76,12 +76,9 @@ func TestCreateInvite(t *testing.T) { | |
assert.NoError(t, user.Set("sub", userEmail)) | ||
|
||
ctx := context.Background() | ||
ctx = authjwt.WithAuthTokenContext(ctx, user) | ||
|
||
idClient := mockauth.NewMockResolver(ctrl) | ||
idClient.EXPECT().Resolve(ctx, userSubject).Return(&auth.Identity{ | ||
ctx = auth.WithIdentityContext(ctx, &auth.Identity{ | ||
UserID: userSubject, | ||
}, nil).AnyTimes() | ||
}) | ||
|
||
publisher := mockevents.NewMockPublisher(ctrl) | ||
if scenario.publisherSetup != nil { | ||
|
@@ -93,7 +90,7 @@ func TestCreateInvite(t *testing.T) { | |
} | ||
|
||
service := NewInviteService() | ||
invite, err := service.CreateInvite(ctx, scenario.dBSetup(ctrl), idClient, publisher, emailConfig, projectId, userRole, userEmail) | ||
invite, err := service.CreateInvite(ctx, scenario.dBSetup(ctrl), publisher, emailConfig, projectId, userRole, userEmail) | ||
|
||
if scenario.expectedError != "" { | ||
require.ErrorContains(t, err, scenario.expectedError) | ||
|
@@ -122,23 +119,23 @@ func TestUpdateInvite(t *testing.T) { | |
{ | ||
name: "error when no existing invites", | ||
dBSetup: dbf.NewDBMock( | ||
withGetUserBySubject(validUser), | ||
// withGetUserBySubject(validUser), | ||
withExistingInvites(noInvites), | ||
), | ||
expectedError: "no invitations found for this email and project", | ||
}, | ||
{ | ||
name: "error when multiple existing invites", | ||
dBSetup: dbf.NewDBMock( | ||
withGetUserBySubject(validUser), | ||
// withGetUserBySubject(validUser), | ||
withExistingInvites(multipleInvites), | ||
), | ||
expectedError: "multiple invitations found for this email and project", | ||
}, | ||
{ | ||
name: "no message sent when role is the same", | ||
dBSetup: dbf.NewDBMock( | ||
withGetUserBySubject(validUser), | ||
// withGetUserBySubject(validUser), | ||
withExistingInvites(singleInviteWithSameRole), | ||
withInviteRoleUpdate(userInvite, nil), | ||
withProject(), | ||
|
@@ -147,7 +144,7 @@ func TestUpdateInvite(t *testing.T) { | |
{ | ||
name: "invite updated and message sent successfully", | ||
dBSetup: dbf.NewDBMock( | ||
withGetUserBySubject(validUser), | ||
// withGetUserBySubject(validUser), | ||
withExistingInvites(singleInviteWithDifferentRole), | ||
withInviteRoleUpdate(userInvite, nil), | ||
withProject(), | ||
|
@@ -174,12 +171,10 @@ func TestUpdateInvite(t *testing.T) { | |
assert.NoError(t, user.Set("sub", userEmail)) | ||
|
||
ctx := context.Background() | ||
ctx = authjwt.WithAuthTokenContext(ctx, user) | ||
|
||
idClient := mockauth.NewMockResolver(ctrl) | ||
idClient.EXPECT().Resolve(ctx, userSubject).Return(&auth.Identity{ | ||
// ctx = authjwt.WithAuthTokenContext(ctx, user) | ||
ctx = auth.WithIdentityContext(ctx, &auth.Identity{ | ||
UserID: userSubject, | ||
}, nil).AnyTimes() | ||
}) | ||
|
||
publisher := mockevents.NewMockPublisher(ctrl) | ||
if scenario.publisherSetup != nil { | ||
|
@@ -191,7 +186,7 @@ func TestUpdateInvite(t *testing.T) { | |
} | ||
|
||
service := NewInviteService() | ||
invite, err := service.UpdateInvite(ctx, scenario.dBSetup(ctrl), idClient, publisher, emailConfig, projectId, userRole, userEmail) | ||
invite, err := service.UpdateInvite(ctx, scenario.dBSetup(ctrl), publisher, emailConfig, projectId, userRole, userEmail) | ||
|
||
if scenario.expectedError != "" { | ||
require.ErrorContains(t, err, scenario.expectedError) | ||
|
@@ -280,7 +275,7 @@ func TestRemoveInvite(t *testing.T) { | |
var ( | ||
projectId = uuid.New() | ||
userEmail = "[email protected]" | ||
userSubject = "subject" | ||
userSubject = uuid.New().String() | ||
userRole = authz.RoleAdmin | ||
inviteCode = "code" | ||
baseUrl = "https://minder.example.com" | ||
|
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