forked from raystack/frontier
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test to cover self onboarding scenario
- Loading branch information
1 parent
52f6eb2
commit 00d32bf
Showing
1 changed file
with
34 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -383,6 +383,40 @@ func TestCreateUser(t *testing.T) { | |
}}, | ||
err: nil, | ||
}, | ||
{ | ||
title: "should return success if user service return nil error", | ||
setup: func(ctx context.Context, us *mocks.UserService, sds *mocks.ServiceDataService, rs *mocks.RelationService) context.Context { | ||
ctx = user.SetContextWithEmail(ctx, "[email protected]") | ||
us.EXPECT().FetchCurrentUser(ctx).Return(user.User{}, user.ErrInvalidEmail) | ||
us.EXPECT().Create(mock.AnythingOfType("*context.valueCtx"), user.User{ | ||
Name: "random user", | ||
Email: "[email protected]", | ||
Metadata: nil, | ||
}).Return( | ||
user.User{ | ||
ID: "new-random-user", | ||
Name: "random user", | ||
Email: "[email protected]", | ||
}, nil) | ||
return ctx | ||
}, | ||
req: &shieldv1beta1.CreateUserRequest{Body: &shieldv1beta1.UserRequestBody{ | ||
Name: "random user", | ||
Email: "[email protected]", | ||
Metadata: &structpb.Struct{}, | ||
}}, | ||
want: &shieldv1beta1.CreateUserResponse{User: &shieldv1beta1.User{ | ||
Id: "new-random-user", | ||
Name: "random user", | ||
Email: "[email protected]", | ||
Metadata: &structpb.Struct{ | ||
Fields: map[string]*structpb.Value{}, | ||
}, | ||
CreatedAt: timestamppb.New(time.Time{}), | ||
UpdatedAt: timestamppb.New(time.Time{}), | ||
}}, | ||
err: nil, | ||
}, | ||
} | ||
|
||
for _, tt := range table { | ||
|