Skip to content

Commit

Permalink
Migrate tests from DynaTest to JUnit5
Browse files Browse the repository at this point in the history
  • Loading branch information
mvysny committed Jan 31, 2025
1 parent 98b869c commit ea150dc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/test/kotlin/com/github/vokorm/MappingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.github.mvysny.dynatest.*
import org.jdbi.v3.core.mapper.reflect.FieldMapper
import java.lang.IllegalStateException
import java.lang.Long
import java.sql.Timestamp
import java.time.Instant
import java.time.LocalDate
import java.util.*
Expand Down Expand Up @@ -178,13 +177,3 @@ fun DynaNodeGroup.dbMappingTests() {
}
}
}

// MSSQL nulls out millis for some reason when running on CI
val Date.withZeroMillis: Date get() {
val result = Timestamp((this as Timestamp).time / 1000 * 1000)
result.nanos = 0
return result
}

val Instant.withZeroNanos: Instant get() = Instant.ofEpochMilli(toEpochMilli())
val <T> List<T>.plusNull: List<T?> get() = toList<T?>() + listOf(null)
13 changes: 13 additions & 0 deletions src/test/kotlin/com/github/vokorm/TestUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import java.io.ByteArrayOutputStream
import java.io.ObjectInputStream
import java.io.ObjectOutputStream
import java.io.Serializable
import java.sql.Timestamp
import java.time.Instant
import java.util.Date
import kotlin.test.expect

val gson: Gson = GsonBuilder().registerJavaTimeAdapters().create()
Expand Down Expand Up @@ -48,3 +51,13 @@ fun Serializable?.serializeToBytes(): ByteArray = ByteArrayOutputStream().also {
fun assumeDockerAvailable() {
Assumptions.assumeTrue(DockerClientFactory.instance().isDockerAvailable(), "Docker not available")
}

// MSSQL nulls out millis for some reason when running on CI
val Date.withZeroMillis: Date get() {
val result = Timestamp((this as Timestamp).time / 1000 * 1000)
result.nanos = 0
return result
}

val Instant.withZeroNanos: Instant get() = Instant.ofEpochMilli(toEpochMilli())
val <T> List<T>.plusNull: List<T?> get() = toList<T?>() + listOf(null)

0 comments on commit ea150dc

Please sign in to comment.