-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[#12048] Migrate tests for DeleteAccountActionTest #13200
base: master
Are you sure you want to change the base?
Conversation
Hi @mingyang143, thank you for your interest in contributing to TEAMMATES!
Please address the above before we proceed to review your PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review, nice work so far!
I think in all of your PRs for the tests migration, it includes your changes for #13195. You can try rebasing your branches, keeping only the commits for the migration.
Course stubCourse = new Course("course-id", "name", Const.DEFAULT_TIME_ZONE, "institute"); | ||
Account stubAccount = new Account(googleId, "name", "[email protected]"); | ||
Instructor instructor = new Instructor(stubCourse, "name", "[email protected]", | ||
false, "", null, new InstructorPrivileges()); | ||
instructor.setAccount(stubAccount); | ||
String[] params = { | ||
Const.ParamsNames.INSTRUCTOR_ID, instructor.getGoogleId(), | ||
}; | ||
DeleteAccountAction action = getAction(params); | ||
MessageOutput actionOutput = (MessageOutput) getJsonResult(action).getOutput(); | ||
assertEquals("Account is successfully deleted.", actionOutput.getMessage()); | ||
assertNull(mockLogic.getInstructorByGoogleId(stubCourse.getId(), instructor.getGoogleId())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that because the actual implementation of the action is so simple(we dont need the logic layer to return us any value etc) and we only need to test for SQL related code we can ignore the datastore method call.
Verifying that sqlLogic.deleteAccountCascade(googleId);
is called once with the correct argument and the json output is correct should be enough.
One idea is to verify(mockLogic, times(1)).deleteAccountCascade(googleId)
provided by Mockito this helps to ensure that the method is called and the INSTRUCTOR_ID
from the request params is passed properly as an argument to the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that since the treatment for both existing and non existing account is the same maybe we can just test this 2 cases:
- Null request params
- Non-Null request params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working on this now and will update soon.
4fb253c
to
8358271
Compare
Hi I have rebased this branch already. |
Part of #12048
Outline of Solution
Change DeleteAccountActionTest.java to ensure compatibility with the PostgreSQL database following the database migration.