diff --git a/pkg/banneduser/banneduser.go b/pkg/banneduser/banneduser.go index 915af8f3..eb218663 100644 --- a/pkg/banneduser/banneduser.go +++ b/pkg/banneduser/banneduser.go @@ -39,7 +39,8 @@ func NewBannedUser(userSignup *toolchainv1alpha1.UserSignup, bannedBy, banReason return bannedUser, nil } -// GetBannedUser returns BannedUser with the provided user email hash if found. Otherwise it returns nil. +// GetBannedUser returns BannedUser with the provided user email hash, if found. +// If not found, it returns an error. func GetBannedUser(ctx context.Context, userEmailHash string, hostClient client.Client, hostNamespace string) (*toolchainv1alpha1.BannedUser, error) { emailHashLabelMatch := client.MatchingLabels(map[string]string{ toolchainv1alpha1.BannedUserEmailHashLabelKey: userEmailHash, @@ -54,5 +55,5 @@ func GetBannedUser(ctx context.Context, userEmailHash string, hostClient client. return &bannedUsers.Items[0], nil } - return nil, nil + return nil, fmt.Errorf("failed to get banned user %s", userEmailHash) } diff --git a/pkg/banneduser/banneduser_test.go b/pkg/banneduser/banneduser_test.go index 01647013..397c8efe 100644 --- a/pkg/banneduser/banneduser_test.go +++ b/pkg/banneduser/banneduser_test.go @@ -151,7 +151,7 @@ func TestGetBannedUser(t *testing.T) { name: "user is not banned", toBan: bannedUser2, wantResult: nil, - wantError: false, + wantError: true, fakeClient: fakeClient, }, {