Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update test user details when creating one #33

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
const (
anonymousUserUID = "AgkGYKUsRifO2O9fTLDuVCMr2hb2" // This is an anonymous user
verifyPhone = "testing/verify_phone"
updateUserDetails = "testing/update_user_profile"
createUserByPhone = "testing/create_user_by_phone"
loginByPhone = "testing/login_by_phone"
removeUserByPhone = "testing/remove_user"
Expand Down Expand Up @@ -299,6 +300,9 @@ func CreateTestPhoneNumberUser(t *testing.T, onboardingClient *InterServiceClien
ctx := context.Background()

phone := TestUserPhoneNumber
firstName := "Test"
lastName := "User"
gender := "Male"
PIN := TestUserPin
flavour := feedlib.FlavourConsumer

Expand Down Expand Up @@ -336,6 +340,31 @@ func CreateTestPhoneNumberUser(t *testing.T, onboardingClient *InterServiceClien
if err != nil {
return nil, fmt.Errorf("failed to unmarshal OTP: %v", err)
}
updateUserProfilePayload := map[string]interface{}{
"uid": response.Auth.UID,
"firstName": firstName,
"lastName": lastName,
"gender": gender,
}
resp, err = onboardingClient.MakeRequest(
ctx,
http.MethodPost,
updateUserDetails,
updateUserProfilePayload,
)
if err != nil {
return nil, fmt.Errorf("unable to update user details: %w", err)
}
updateDetailsResp, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("unable to convert response to string: %v", err)
}

var userProfile *profileutils.UserProfile
err = json.Unmarshal(updateDetailsResp, &userProfile)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal OTP: %v", err)
}

return response, nil
}
Expand Down
6 changes: 6 additions & 0 deletions test_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ func TestCreateOrLoginTestPhoneNumberUser(t *testing.T) {
type args struct {
onboardingClient *interserviceclient.InterServiceClient
}
// clean of any pre-existing test users
err = interserviceclient.RemoveTestPhoneNumberUser(t, onboardingClient)
if err != nil {
t.Errorf("failed to remove test user: %v", err)
return
}
tests := []struct {
name string
args args
Expand Down
Loading