Skip to content

Commit

Permalink
fix flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mvysny committed Jan 24, 2024
1 parent 9843cb0 commit 1e00b3b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/test/kotlin/com/github/vokorm/Person.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ data class Person(

override fun save(validate: Boolean) {
if (id == null) {
if (created == null) created = java.sql.Timestamp(System.currentTimeMillis())
if (created == null) created = java.sql.Timestamp(System.currentTimeMillis()).withZeroMillis
// otherwise we can't test 'search by `modified`'
if (modified == null) modified = Instant.ofEpochMilli(1238123123L)
if (modified == null) modified = Instant.ofEpochMilli(1238123123L).withZeroNanos
}
super.save(validate)
}
Expand All @@ -49,7 +49,8 @@ data class Person(
val IGNORE_THIS_FIELD: Int = 0
}

fun withZeroNanos(): Person = copy(created = created?.withZeroMillis, modified = modified?.withZeroNanos)
@Deprecated("no need")
fun withZeroNanos(): Person = this
}

enum class MaritalStatus {
Expand Down

0 comments on commit 1e00b3b

Please sign in to comment.