Skip to content

Commit 632556a

Browse files
committed
Migrate to AssertK
1 parent 0657e94 commit 632556a

File tree

11 files changed

+32
-34
lines changed

11 files changed

+32
-34
lines changed

copper-flow/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies {
99

1010
androidTestImplementation project(':copper-testing')
1111
androidTestImplementation libs.androidx.test.runner
12-
androidTestImplementation libs.truth
12+
androidTestImplementation libs.assertk
1313
androidTestImplementation libs.turbine
1414
}
1515

copper-flow/src/androidTest/java/app/cash/copper/flow/AsRowsTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import app.cash.copper.testing.Employee
55
import app.cash.copper.testing.Employee.Companion.queryOf
66
import app.cash.copper.testing.NullQuery
77
import app.cash.turbine.test
8-
import com.google.common.truth.Truth.assertThat
8+
import assertk.assertThat
9+
import assertk.assertions.isEqualTo
10+
import kotlin.time.ExperimentalTime
911
import kotlinx.coroutines.ExperimentalCoroutinesApi
1012
import kotlinx.coroutines.flow.take
1113
import kotlinx.coroutines.runBlocking
1214
import org.junit.Test
1315
import org.junit.runner.RunWith
14-
import kotlin.time.ExperimentalTime
1516

1617
@ExperimentalCoroutinesApi
1718
@ExperimentalTime

copper-flow/src/androidTest/java/app/cash/copper/flow/OperatorTest.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ import android.database.Cursor
1919
import app.cash.copper.testing.Employee
2020
import app.cash.copper.testing.Employee.Companion.queryOf
2121
import app.cash.copper.testing.NullQuery
22-
import app.cash.copper.testing.assert
2322
import app.cash.turbine.test
24-
import com.google.common.truth.Truth.assertThat
23+
import assertk.assertThat
24+
import assertk.assertions.containsExactly
25+
import assertk.assertions.hasMessage
26+
import assertk.assertions.isEmpty
27+
import assertk.assertions.isEqualTo
28+
import assertk.assertions.isInstanceOf
2529
import kotlinx.coroutines.ExperimentalCoroutinesApi
2630
import kotlinx.coroutines.flow.flowOf
2731
import kotlinx.coroutines.runBlocking
@@ -53,9 +57,9 @@ class OperatorTest {
5357
flowOf(queryOf("alice", "Alice Allison", "bob", "Bob Bobberson"))
5458
.mapToOne(mapper = Employee.MAPPER)
5559
.test {
56-
awaitError().assert {
57-
isInstanceOf(IllegalStateException::class.java)
58-
hasMessageThat().isEqualTo("Cursor returned more than 1 row")
60+
assertThat(awaitError())
61+
.isInstanceOf<IllegalStateException>()
62+
.hasMessage("Cursor returned more than 1 row")
5963
}
6064
}
6165
}
@@ -156,9 +160,9 @@ class OperatorTest {
156160
flowOf(queryOf("alice", "Alice Allison", "bob", "Bob Bobberson"))
157161
.mapToOneOrNull(mapper = Employee.MAPPER)
158162
.test {
159-
awaitError().assert {
160-
isInstanceOf(IllegalStateException::class.java)
161-
hasMessageThat().isEqualTo("Cursor returned more than 1 row")
163+
assertThat(awaitError())
164+
.isInstanceOf<IllegalStateException>()
165+
.hasMessage("Cursor returned more than 1 row")
162166
}
163167
}
164168
}

copper-rx2/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies {
99

1010
androidTestImplementation project(':copper-testing')
1111
androidTestImplementation libs.androidx.test.runner
12-
androidTestImplementation libs.truth
12+
androidTestImplementation libs.assertk
1313
}
1414

1515
android {

copper-rx2/src/androidTest/java/app/cash/copper/rx2/AsRowsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.junit.runner.RunWith;
1212

1313
import static app.cash.copper.testing.Employee.queryOf;
14-
import static com.google.common.truth.Truth.assertThat;
14+
import static org.junit.Assert.assertEquals;
1515

1616
@RunWith(AndroidJUnit4.class)
1717
@SuppressWarnings("CheckResult")
@@ -45,7 +45,7 @@ public final class AsRowsTest {
4545
.test()
4646
.assertValue(new Employee("alice", "Alice Allison"))
4747
.assertComplete();
48-
assertThat(count.get()).isEqualTo(1);
48+
assertEquals(1, count.get());
4949
}
5050

5151
@Test public void asRowsEmptyWhenNullCursor() {
@@ -60,6 +60,6 @@ public final class AsRowsTest {
6060
.assertNoValues()
6161
.assertComplete();
6262

63-
assertThat(count.get()).isEqualTo(0);
63+
assertEquals(0, count.get());
6464
}
6565
}

copper-rx3/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies {
99

1010
androidTestImplementation project(':copper-testing')
1111
androidTestImplementation libs.androidx.test.runner
12-
androidTestImplementation libs.truth
12+
androidTestImplementation libs.assertk
1313
}
1414

1515
android {

copper-rx3/src/androidTest/java/app/cash/copper/rx3/AsRowsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.junit.runner.RunWith;
1212

1313
import static app.cash.copper.testing.Employee.queryOf;
14-
import static com.google.common.truth.Truth.assertThat;
14+
import static org.junit.Assert.assertEquals;
1515

1616
@RunWith(AndroidJUnit4.class)
1717
@SuppressWarnings("CheckResult")
@@ -45,7 +45,7 @@ public final class AsRowsTest {
4545
.test()
4646
.assertValue(new Employee("alice", "Alice Allison"))
4747
.assertComplete();
48-
assertThat(count.get()).isEqualTo(1);
48+
assertEquals(1, count.get());
4949
}
5050

5151
@Test public void asRowsEmptyWhenNullCursor() {
@@ -60,6 +60,6 @@ public final class AsRowsTest {
6060
.assertNoValues()
6161
.assertComplete();
6262

63-
assertThat(count.get()).isEqualTo(0);
63+
assertEquals(0, count.get());
6464
}
6565
}

copper-testing/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apply plugin: 'org.jetbrains.kotlin.android'
33

44
dependencies {
55
api project(':copper')
6-
api libs.truth
6+
api libs.assertk
77
}
88

99
android {

copper-testing/src/main/java/app/cash/copper/testing/CursorAssert.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@ package app.cash.copper.testing
22

33
import android.database.Cursor
44
import app.cash.copper.Query
5-
import com.google.common.truth.Truth.assertWithMessage
5+
import assertk.assertThat
6+
import assertk.assertions.isEqualTo
7+
import assertk.assertions.isTrue
68

79
class CursorAssert(private val cursor: Cursor) {
810
private var row = 0
911

1012
fun hasRow(vararg values: Any?) = apply {
11-
assertWithMessage("row " + (row + 1) + " exists")
12-
.that(cursor.moveToNext())
13-
.isTrue()
13+
assertThat(cursor.moveToNext(), name = "row ${row + 1} exists").isTrue()
1414
row += 1
15-
assertWithMessage("column count").that(cursor.columnCount).isEqualTo(values.size)
15+
assertThat(cursor.columnCount, name = "column count").isEqualTo(values.size)
1616
for (i in values.indices) {
17-
assertWithMessage("row " + row + " column '" + cursor.getColumnName(i) + "'")
18-
.that(cursor.getString(i))
17+
assertThat(cursor.getString(i), name = "row $row column '${cursor.getColumnName(i)}'")
1918
.isEqualTo(values[i])
2019
}
2120
}

copper-testing/src/main/java/app/cash/copper/testing/truth.kt

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)