Skip to content

Commit

Permalink
adds tests for delete user
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhpoddar committed Dec 15, 2023
1 parent 5f1c20c commit 3e190bb
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 86 deletions.
44 changes: 44 additions & 0 deletions recipe/emailpassword/accountlinkingRecipeImplementation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,50 @@ func TestUnlinkAccountsWithDeleteUserSuccess(t *testing.T) {
assert.True(t, unlinkResponse.WasLinked)
}

func TestDeleteUser(t *testing.T) {
telemetry := false
configValue := supertokens.TypeInput{
Telemetry: &telemetry,
Supertokens: &supertokens.ConnectionInfo{
ConnectionURI: "http://localhost:8080",
},
AppInfo: supertokens.AppInfo{
APIDomain: "api.supertokens.io",
AppName: "SuperTokens",
WebsiteDomain: "supertokens.io",
},
RecipeList: []supertokens.Recipe{
Init(nil),
},
}
BeforeEach()
unittesting.StartUpST("localhost", "8080")
defer AfterEach()
err := supertokens.Init(configValue)
if err != nil {
t.Error(err.Error())
}

res, err := SignUp("public", "[email protected]", "1234abcd")
if err != nil {
t.Error(err.Error())
}
reponseBeforeDeletingUser, err := supertokens.GetUsersOldestFirst("public", nil, nil, nil, nil)
if err != nil {
t.Error(err.Error())
}
assert.Equal(t, 1, len(reponseBeforeDeletingUser.Users))
err = supertokens.DeleteUser(res.OK.User.ID, true)
if err != nil {
t.Error(err.Error())
}
responseAfterDeletingUser, err := supertokens.GetUsersOldestFirst("public", nil, nil, nil, nil)
if err != nil {
t.Error(err.Error())
}
assert.Equal(t, 0, len(responseAfterDeletingUser.Users))
}

// TODO: remove this function
func convertEpUserToSuperTokensUser(epuser epmodels.User) supertokens.User {
rUId, err := supertokens.NewRecipeUserID(epuser.ID)
Expand Down
84 changes: 0 additions & 84 deletions recipe/emailpassword/deleteUser_test.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,7 @@ func TestEmailVerifyWithDeletedUser(t *testing.T) {

userId := response["user"].(map[string]interface{})["id"]
cookieData := unittesting.ExtractInfoFromResponse(resp)
supertokens.DeleteUser(userId.(string))
supertokens.DeleteUser(userId.(string), true)

resp1, err := unittesting.EmailVerifyTokenRequest(testServer.URL, userId.(string), cookieData["sAccessToken"], cookieData["antiCsrf"])

Expand Down
2 changes: 1 addition & 1 deletion recipe/emailpassword/userIdMapping_users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestCreateUserIdMappingAndDeleteUser(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, createResp.OK)

err = supertokens.DeleteUser(externalUserId)
err = supertokens.DeleteUser(externalUserId, true)
assert.NoError(t, err)
}

Expand Down

0 comments on commit 3e190bb

Please sign in to comment.