File tree 2 files changed +22
-14
lines changed 2 files changed +22
-14
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2019-2025 JetBrains s.r.o. and contributors.
3
+ * Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4
+ */
5
+
6
+ package kotlinx.datetime.test
7
+
8
+ import kotlinx.cinterop.ExperimentalForeignApi
9
+ import kotlinx.cinterop.toKString
10
+ import platform.posix.getenv
11
+
12
+ object Testcontainers {
13
+
14
+ @OptIn(ExperimentalForeignApi ::class )
15
+ val available: Boolean
16
+ get() = getenv(" INSIDE_TESTCONTAINERS" )?.toKString()?.toBoolean() == true
17
+
18
+ inline fun runIfAvailable (block : () -> Unit ) {
19
+ if (available) block() else println (" Skipping test that requires testcontainers..." )
20
+ }
21
+ }
Original file line number Diff line number Diff line change 5
5
6
6
package kotlinx.datetime.test
7
7
8
- import kotlinx.cinterop.ExperimentalForeignApi
9
- import kotlinx.cinterop.toKString
10
8
import kotlinx.datetime.*
11
9
import kotlin.test.*
12
- import platform.posix.getenv
13
10
14
11
class TimeZoneLinuxNativeTest {
15
12
16
- private var shouldRunTests = false
17
-
18
- @OptIn(ExperimentalForeignApi ::class )
19
- @BeforeTest
20
- fun setup () {
21
- shouldRunTests = getenv(" INSIDE_TESTCONTAINERS" )?.toKString() != null
22
- }
23
-
24
13
@Test
25
- fun defaultTimeZoneTest () {
26
- if (! shouldRunTests) return
27
-
14
+ fun defaultTimeZoneTest () = Testcontainers .runIfAvailable {
28
15
val tz = TimeZone .currentSystemDefault()
29
16
println (" TIMEZONE: $tz " )
30
17
assertEquals(TimeZone .of(" Europe/Oslo" ), tz)
You can’t perform that action at this time.
0 commit comments