Skip to content

Commit

Permalink
tests: replace hardcoded date with dynamic value
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-sucena committed Oct 26, 2024
1 parent 279d0e6 commit 722f705
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pt.up.fe.ni.website.backend.utils

import java.time.LocalDate
import org.springframework.http.MediaType
import org.springframework.test.web.servlet.ResultActions
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.content
Expand Down Expand Up @@ -112,13 +113,18 @@ class ValidationTester(
}

fun isPastDate() {
// get the current date and offset it by 1 day
val tomorrow = LocalDate.now()
.plusDays(1)
.toString()

val params = requiredFields.toMutableMap()
params[param] = "01-01-3000" // TODO: use a date in the future instead of hard coded
params[param] = tomorrow
req(params)
.expectValidationError()
.andExpectAll(
jsonPath("$.errors[0].message").value("must be a past date"),
jsonPath("$.errors[0].value").value("01-01-3000")
jsonPath("$.errors[0].value").value(tomorrow)
)
}

Expand Down

0 comments on commit 722f705

Please sign in to comment.