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

[#12048] Migrate tests for DeleteAccountActionTest #13200

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mingyang143
Copy link

Part of #12048

Outline of Solution
Change DeleteAccountActionTest.java to ensure compatibility with the PostgreSQL database following the database migration.

Copy link

Hi @mingyang143, thank you for your interest in contributing to TEAMMATES!
However, your PR does not appear to follow our contribution guidelines:

  • Title must start with the issue number the PR is fixing in square brackets, e.g. [#<issue-number>]

Please address the above before we proceed to review your PR.

@mingyang143 mingyang143 changed the title Migrate tests for DeleteAccountActionTest [#12048] Migrate tests for DeleteAccountActionTest Jan 22, 2025
Copy link
Contributor

@dishenggg dishenggg left a 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.

Comment on lines +41 to +52
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()));
Copy link
Contributor

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.

Copy link
Contributor

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:

  1. Null request params
  2. Non-Null request params

Copy link
Author

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.

@dishenggg dishenggg added the s.Ongoing The PR is being worked on by the author(s) label Feb 6, 2025
@mingyang143
Copy link
Author

mingyang143 commented Feb 6, 2025

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.

Hi I have rebased this branch already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s.Ongoing The PR is being worked on by the author(s)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants