Skip to content

Commit 2104fd9

Browse files
committed
Fix formatting
1 parent 025c79f commit 2104fd9

File tree

2 files changed

+50
-35
lines changed

2 files changed

+50
-35
lines changed

integrations/supabase/src/commonIntegrationTest/kotlin/com/powersync/connector/supabase/SupabaseConnectorTest.kt

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,55 @@ import kotlinx.coroutines.test.runTest
1313
import kotlin.test.Test
1414

1515
class SupabaseConnectorTest {
16-
1716
@Test
18-
fun errorHandling() = runTest {
19-
val db = PowerSyncDatabase.inMemory(scope=this, schema= Schema(Table("users", listOf(
20-
Column.text("name")
21-
))))
22-
23-
try {
24-
db.writeTransaction { tx ->
25-
tx.execute("INSERT INTO users (id, name) VALUES (uuid(), ?)", listOf("a"))
26-
tx.execute("INSERT INTO users (id, name) VALUES (uuid(), ?)", listOf("b"))
27-
tx.execute("INSERT INTO users (id, name) VALUES (uuid(), ?)", listOf("c"))
28-
}
17+
fun errorHandling() =
18+
runTest {
19+
val db =
20+
PowerSyncDatabase.inMemory(
21+
scope = this,
22+
schema =
23+
Schema(
24+
Table(
25+
"users",
26+
listOf(
27+
Column.text("name"),
28+
),
29+
),
30+
),
31+
)
2932

30-
var calledErrorHandler = false
31-
val connector = object : SupabaseConnector("", "", "") {
32-
override suspend fun uploadCrudEntry(entry: CrudEntry) {
33-
throw Exception("Expected exception, failing in uploadCrudEntry")
33+
try {
34+
db.writeTransaction { tx ->
35+
tx.execute("INSERT INTO users (id, name) VALUES (uuid(), ?)", listOf("a"))
36+
tx.execute("INSERT INTO users (id, name) VALUES (uuid(), ?)", listOf("b"))
37+
tx.execute("INSERT INTO users (id, name) VALUES (uuid(), ?)", listOf("c"))
3438
}
3539

36-
override suspend fun handleError(
37-
tx: CrudTransaction,
38-
entry: CrudEntry,
39-
exception: Exception,
40-
errorCode: String?
41-
) {
42-
calledErrorHandler = true
40+
var calledErrorHandler = false
41+
val connector =
42+
object : SupabaseConnector("", "", "") {
43+
override suspend fun uploadCrudEntry(entry: CrudEntry): Unit =
44+
throw Exception("Expected exception, failing in uploadCrudEntry")
4345

44-
tx.crud shouldHaveSize 3
45-
entry shouldBeEqual tx.crud[0]
46-
exception.message shouldBe "Expected exception, failing in uploadCrudEntry"
47-
tx.complete(null)
48-
}
49-
}
46+
override suspend fun handleError(
47+
tx: CrudTransaction,
48+
entry: CrudEntry,
49+
exception: Exception,
50+
errorCode: String?,
51+
) {
52+
calledErrorHandler = true
53+
54+
tx.crud shouldHaveSize 3
55+
entry shouldBeEqual tx.crud[0]
56+
exception.message shouldBe "Expected exception, failing in uploadCrudEntry"
57+
tx.complete(null)
58+
}
59+
}
5060

51-
connector.uploadData(db)
52-
calledErrorHandler shouldBe true
53-
} finally {
54-
db.close()
61+
connector.uploadData(db)
62+
calledErrorHandler shouldBe true
63+
} finally {
64+
db.close()
65+
}
5566
}
56-
}
5767
}

integrations/supabase/src/commonMain/kotlin/com/powersync/connector/supabase/SupabaseConnector.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,12 @@ public open class SupabaseConnector(
221221
* @throws Exception If the upload should be retried. If this method doesn't throw, it should mark [tx] as complete
222222
* by invoking [CrudTransaction.complete]. In that case, the local write would be lost.
223223
*/
224-
public open suspend fun handleError(tx: CrudTransaction, entry: CrudEntry, exception: Exception, errorCode: String?) {
224+
public open suspend fun handleError(
225+
tx: CrudTransaction,
226+
entry: CrudEntry,
227+
exception: Exception,
228+
errorCode: String?,
229+
) {
225230
if (errorCode != null && isFatalError(errorCode)) {
226231
/**
227232
* Instead of blocking the queue with these errors,

0 commit comments

Comments
 (0)