Issue with UserTest.testDeleteUser()

In UserTest.testDeleteUser(), we first call addUser(). addUser just adds a user to users collection, and no addition is done to sessions collection.
Then we call deleteUser(), which deletes from users collection.
Then we call getUserSession and verify that no session is found, expecting that deleteUser has cleaned up the sessions collection too. But we haven’t done that. If we do clean sessions in deleteUser, then we need to add session in addUser() implementation(needed to correctly return the boolean).
Current implementations of these methods and calls in UserTest.testDeleteUser() are contradicting each other.

Manish, you do not need to create a session when a user is created (this will be created when he/she logon to the app), but you indeed will need to make sure that all user’s sessions are closed (or deleted) before deleting the user. Hope this helps !

1 Like