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

tests: replace hardcoded date with dynamic value #207

Merged
merged 2 commits into from
Nov 6, 2024

Conversation

tomas-sucena
Copy link
Contributor

@tomas-sucena tomas-sucena commented Oct 26, 2024

Closes #53

Replace the hardcoded date with tomorrow's string representation in the isPastDate validator test.

fun isPastDate() {
      // get the current date and offset it by 1 day
      val timeFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy")
      val tomorrow = LocalDate.now()
          .plusDays(1)
          .format(timeFormatter)
          .toString()

      val params = requiredFields.toMutableMap()
      params[param] = tomorrow
      req(params)
          .expectValidationError()
          .andExpectAll(
              jsonPath("$.errors[0].message").value("must be a past date"),
              jsonPath("$.errors[0].value").value(tomorrow)
          )
}

Review checklist

  • Behavior is as expected
  • Clean, well structured code
  • Properly documents API changes in the corresponding controller test
  • Contains enough appropriate tests
  • Changes are reflected in the Wiki if necessary

@tomas-sucena tomas-sucena requested review from MRita443 and removed request for MRita443 October 26, 2024 15:26
@tomas-sucena tomas-sucena reopened this Oct 26, 2024
Copy link

Check the documentation preview: https://671d15479dee5010d0ea5348--niaefeup-backend-docs.netlify.app

Copy link

Check the documentation preview: https://671d156c9cfbdff502a196cc--niaefeup-backend-docs.netlify.app

Copy link
Member

@BrunoRosendo BrunoRosendo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! 👏

Copy link
Collaborator

@MRita443 MRita443 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job and initiative! :)

@MRita443 MRita443 merged commit 55ddb2d into develop Nov 6, 2024
6 checks passed
@MRita443 MRita443 deleted the tests/refactor-isPastDate-validator branch November 6, 2024 13:03
Copy link

github-actions bot commented Nov 6, 2024

Check the documentation preview:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tests: don't use a hard-coded date in isPastDate validator
3 participants