-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* improve IsAlreadyBanned * requested changes
- Loading branch information
Showing
4 changed files
with
18 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,7 +111,7 @@ func TestNewBannedUser(t *testing.T) { | |
} | ||
} | ||
|
||
func TestIsAlreadyBanned(t *testing.T) { | ||
func TestGetBannedUser(t *testing.T) { | ||
userSignup1 := commonsignup.NewUserSignup(commonsignup.WithName("johny"), commonsignup.WithEmail("[email protected]")) | ||
userSignup2 := commonsignup.NewUserSignup(commonsignup.WithName("bob"), commonsignup.WithEmail("[email protected]")) | ||
userSignup3 := commonsignup.NewUserSignup(commonsignup.WithName("oliver"), commonsignup.WithEmail("[email protected]")) | ||
|
@@ -129,36 +129,36 @@ func TestIsAlreadyBanned(t *testing.T) { | |
tests := []struct { | ||
name string | ||
toBan *toolchainv1alpha1.BannedUser | ||
wantResult bool | ||
wantResult *toolchainv1alpha1.BannedUser | ||
wantError bool | ||
fakeClient *test.FakeClient | ||
}{ | ||
{ | ||
name: "user is already banned", | ||
toBan: bannedUser1, | ||
wantResult: true, | ||
wantResult: bannedUser1, | ||
wantError: false, | ||
fakeClient: fakeClient, | ||
}, | ||
{ | ||
name: "user is not banned", | ||
toBan: bannedUser2, | ||
wantResult: false, | ||
wantResult: nil, | ||
wantError: false, | ||
fakeClient: fakeClient, | ||
}, | ||
{ | ||
name: "cannot list banned users because the client does have type v1alpha1.BannedUserList registered in the scheme", | ||
toBan: bannedUser3, | ||
wantResult: false, | ||
wantResult: nil, | ||
wantError: true, | ||
fakeClient: &test.FakeClient{Client: fake.NewClientBuilder().WithScheme(scheme.Scheme).Build(), T: t}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
gotResult, err := IsAlreadyBanned(ctx, tt.toBan.Labels[toolchainv1alpha1.BannedUserEmailHashLabelKey], tt.fakeClient, test.HostOperatorNs) | ||
gotResult, err := GetBannedUser(ctx, tt.toBan.Labels[toolchainv1alpha1.BannedUserEmailHashLabelKey], tt.fakeClient, test.HostOperatorNs) | ||
|
||
if tt.wantError { | ||
require.Error(t, err) | ||
|