-
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
[#12048] Migrate tests for DeleteAccountActionTest #13200
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.
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 have updated the tests. Let me know if further fixes are needed, thanks!
4fb253c
to
8358271
Compare
Hi I have rebased this branch already. |
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.
Nice work! LGTM
} | ||
|
||
@Test | ||
protected void textExecute_nullParams_failSilently() { |
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.
one small nit here, maybe we can update the name of this test since verifyHttpParameterFailure
actually checks if an exception is thrown
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.
Thanks for the PR review! I've made the updates as requested.
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.
LGTM, good work!
[TEAMMATES#12048] Migrate tests for DeleteAccountActionTest (TEAMMATES#13200)
…S#13200) * Migrate DeleteAccountActionTest * Fix checkstyle * Modify tests in DeleteAccountActionTest.java * Update method name in DeleteAccountActionTest
* Migrate tests for GetCoursesActionTest.java * [#12048] Migrate tests for DeleteAccountActionTest (#13200) * Migrate DeleteAccountActionTest * Fix checkstyle * Modify tests in DeleteAccountActionTest.java * Update method name in DeleteAccountActionTest * [#12048] Migrate tests for DeleteFeedbackQuestionActionTest (#13218) * Migrate tests for GetCoursesActionTest * Update PR for GetCoursesActionTest * Update PR for GetCoursesActionTest * Update PR for GetCoursesActionTest --------- Co-authored-by: Wei Loon <[email protected]> Co-authored-by: Jason Qiu <[email protected]> Co-authored-by: domoberzin <[email protected]>
Part of #12048
Outline of Solution
Change DeleteAccountActionTest.java to ensure compatibility with the PostgreSQL database following the database migration.