Skip to content

Commit fc08cb9

Browse files
#430: Check INSIDE_TESTCONTAINERS env var to run test only in testcontainer
1 parent d294ac1 commit fc08cb9

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

core/jvm/test/testcontainers/modified/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ FROM --platform=linux/arm64 ubuntu:24.04
22

33
RUN apt-get update && apt-get install -y tzdata
44

5+
ENV INSIDE_TESTCONTAINERS=true
6+
57
# 4: Arctic/Longyearbyen
68
RUN echo 4 | dpkg-reconfigure tzdata
79

core/jvm/test/testcontainers/original/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ FROM --platform=linux/arm64 ubuntu:24.04
22

33
RUN apt-get update && apt-get install -y tzdata
44

5+
ENV INSIDE_TESTCONTAINERS=true
6+
57
# 4: Arctic/Longyearbyen
68
RUN echo 4 | dpkg-reconfigure tzdata
79

core/linux/test/TimeZoneLinuxNativeTest.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,28 @@
55

66
package kotlinx.datetime.test
77

8+
import kotlinx.cinterop.ExperimentalForeignApi
9+
import kotlinx.cinterop.toKString
810
import kotlinx.datetime.*
911
import kotlin.test.*
12+
import platform.posix.getenv
1013

1114
class TimeZoneLinuxNativeTest {
15+
16+
private var shouldRunTests = false
17+
18+
@OptIn(ExperimentalForeignApi::class)
19+
@BeforeTest
20+
fun setup() {
21+
shouldRunTests = getenv("INSIDE_TESTCONTAINERS")?.toKString() != null
22+
}
23+
1224
@Test
1325
fun defaultTimeZoneTest() {
26+
if (!shouldRunTests) return
27+
1428
val tz = TimeZone.currentSystemDefault()
15-
println("LINUX TIMEZONE: $tz")
29+
println("TIMEZONE: $tz")
1630
assertEquals(TimeZone.of("Europe/Oslo"), tz)
1731
}
1832
}

0 commit comments

Comments
 (0)