Skip to content

Commit

Permalink
test: add test to cover self onboarding scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
ishanarya0 committed Jul 24, 2024
1 parent 52f6eb2 commit 00d32bf
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions internal/api/v1beta1/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 00d32bf

Please sign in to comment.