Skip to content

Commit 8780792

Browse files
committed
Consistently use runBlockingTest
1 parent e4f2c4a commit 8780792

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/test/kotlin/com/github/michaelbull/jdbc/context/CoroutineConnectionTest.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.github.michaelbull.jdbc.context
22

33
import io.mockk.mockk
44
import kotlinx.coroutines.ExperimentalCoroutinesApi
5-
import kotlinx.coroutines.runBlocking
5+
import kotlinx.coroutines.test.runBlockingTest
66
import org.junit.jupiter.api.Assertions.assertEquals
77
import org.junit.jupiter.api.Test
88
import org.junit.jupiter.api.assertThrows
@@ -14,15 +14,17 @@ class CoroutineConnectionTest {
1414
@Test
1515
fun `connection throws IllegalStateException if not in context`() {
1616
assertThrows<IllegalStateException> {
17-
runBlocking { coroutineContext.connection }
17+
runBlockingTest {
18+
coroutineContext.connection
19+
}
1820
}
1921
}
2022

2123
@Test
2224
fun `connection returns connection if in context`() {
2325
val expected = mockk<Connection>()
2426

25-
runBlocking(CoroutineConnection(expected)) {
27+
runBlockingTest(CoroutineConnection(expected)) {
2628
val actual = coroutineContext.connection
2729
assertEquals(expected, actual)
2830
}

src/test/kotlin/com/github/michaelbull/jdbc/context/CoroutineDataSourceTest.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.github.michaelbull.jdbc.context
22

33
import io.mockk.mockk
44
import kotlinx.coroutines.ExperimentalCoroutinesApi
5-
import kotlinx.coroutines.runBlocking
5+
import kotlinx.coroutines.test.runBlockingTest
66
import org.junit.jupiter.api.Assertions
77
import org.junit.jupiter.api.Test
88
import org.junit.jupiter.api.assertThrows
@@ -14,15 +14,17 @@ class CoroutineDataSourceTest {
1414
@Test
1515
fun `dataSource throws IllegalStateException if not in context`() {
1616
assertThrows<IllegalStateException> {
17-
runBlocking { coroutineContext.dataSource }
17+
runBlockingTest {
18+
coroutineContext.dataSource
19+
}
1820
}
1921
}
2022

2123
@Test
2224
fun `dataSource returns connection if in context`() {
2325
val expected = mockk<DataSource>()
2426

25-
runBlocking(CoroutineDataSource(expected)) {
27+
runBlockingTest(CoroutineDataSource(expected)) {
2628
val actual = coroutineContext.dataSource
2729
Assertions.assertEquals(expected, actual)
2830
}

0 commit comments

Comments
 (0)