Skip to content

Commit 29eb968

Browse files
committed
Reformat
1 parent 6788119 commit 29eb968

File tree

5 files changed

+57
-55
lines changed

5 files changed

+57
-55
lines changed

core/src/commonIntegrationTest/kotlin/com/powersync/SyncIntegrationTest.kt

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -120,62 +120,65 @@ class SyncIntegrationTest {
120120

121121
@Test
122122
@OptIn(DelicateCoroutinesApi::class)
123-
fun closesResponseStreamOnDatabaseClose() = runTest {
124-
val syncStream = syncStream()
125-
database.connectInternal(syncStream, 1000L)
123+
fun closesResponseStreamOnDatabaseClose() =
124+
runTest {
125+
val syncStream = syncStream()
126+
database.connectInternal(syncStream, 1000L)
126127

127-
turbineScope(timeout = 10.0.seconds) {
128-
val turbine = database.currentStatus.asFlow().testIn(this)
129-
turbine.waitFor { it.connected }
128+
turbineScope(timeout = 10.0.seconds) {
129+
val turbine = database.currentStatus.asFlow().testIn(this)
130+
turbine.waitFor { it.connected }
130131

131-
database.close()
132-
turbine.waitFor { !it.connected }
133-
turbine.cancel()
134-
}
132+
database.close()
133+
turbine.waitFor { !it.connected }
134+
turbine.cancel()
135+
}
135136

136-
// Closing the database should have closed the channel
137-
assertTrue { syncLines.isClosedForSend }
138-
}
137+
// Closing the database should have closed the channel
138+
assertTrue { syncLines.isClosedForSend }
139+
}
139140

140141
@Test
141142
@OptIn(DelicateCoroutinesApi::class)
142-
fun cleansResourcesOnDisconnect() = runTest {
143-
val syncStream = syncStream()
144-
database.connectInternal(syncStream, 1000L)
143+
fun cleansResourcesOnDisconnect() =
144+
runTest {
145+
val syncStream = syncStream()
146+
database.connectInternal(syncStream, 1000L)
145147

146-
turbineScope(timeout = 10.0.seconds) {
147-
val turbine = database.currentStatus.asFlow().testIn(this)
148-
turbine.waitFor { it.connected }
148+
turbineScope(timeout = 10.0.seconds) {
149+
val turbine = database.currentStatus.asFlow().testIn(this)
150+
turbine.waitFor { it.connected }
149151

150-
database.disconnect()
151-
turbine.waitFor { !it.connected }
152-
turbine.cancel()
153-
}
152+
database.disconnect()
153+
turbine.waitFor { !it.connected }
154+
turbine.cancel()
155+
}
154156

155-
// Disconnecting should have closed the channel
156-
assertTrue { syncLines.isClosedForSend }
157+
// Disconnecting should have closed the channel
158+
assertTrue { syncLines.isClosedForSend }
157159

158-
// And called invalidateCredentials on the connector
159-
verify { connector.invalidateCredentials() }
160-
}
160+
// And called invalidateCredentials on the connector
161+
verify { connector.invalidateCredentials() }
162+
}
161163

162164
@Test
163-
fun cannotUpdateSchemaWhileConnected() = runTest {
164-
val syncStream = syncStream()
165-
database.connectInternal(syncStream, 1000L)
166-
167-
turbineScope(timeout = 10.0.seconds) {
168-
val turbine = database.currentStatus.asFlow().testIn(this)
169-
turbine.waitFor { it.connected }
170-
turbine.cancel()
171-
}
165+
fun cannotUpdateSchemaWhileConnected() =
166+
runTest {
167+
val syncStream = syncStream()
168+
database.connectInternal(syncStream, 1000L)
172169

173-
assertFailsWith<PowerSyncException>("Cannot update schema while connected") {
174-
database.updateSchema(Schema())
175-
}
170+
turbineScope(timeout = 10.0.seconds) {
171+
val turbine = database.currentStatus.asFlow().testIn(this)
172+
turbine.waitFor { it.connected }
173+
turbine.cancel()
174+
}
176175

177-
database.close()
178-
}
176+
assertFailsWith<PowerSyncException>("Cannot update schema while connected") {
177+
database.updateSchema(Schema())
178+
}
179+
180+
database.close()
181+
}
179182

180183
@Test
181184
fun testPartialSync() =

core/src/commonMain/kotlin/com/powersync/db/PowerSyncDatabaseImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,4 +488,4 @@ internal class PowerSyncDatabaseImpl(
488488
}
489489
}
490490

491-
internal object DisconnectRequestedException: CancellationException("disconnect() called")
491+
internal object DisconnectRequestedException : CancellationException("disconnect() called")

core/src/commonMain/kotlin/com/powersync/sync/SyncStatus.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import com.powersync.connectors.PowerSyncBackendConnector
55
import kotlinx.coroutines.flow.MutableStateFlow
66
import kotlinx.coroutines.flow.SharedFlow
77
import kotlinx.coroutines.flow.asSharedFlow
8-
import kotlinx.coroutines.flow.cancel
98
import kotlinx.datetime.Instant
109

1110
@ConsistentCopyVisibility

core/src/commonTest/kotlin/com/powersync/sync/SyncStreamTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import dev.mokkery.verifySuspend
3030
import io.ktor.client.engine.mock.MockEngine
3131
import kotlinx.coroutines.channels.Channel
3232
import kotlinx.coroutines.delay
33-
import kotlinx.coroutines.flow.receiveAsFlow
3433
import kotlinx.coroutines.launch
3534
import kotlinx.coroutines.test.runTest
3635
import kotlinx.coroutines.withTimeout

core/src/commonTest/kotlin/com/powersync/testutils/MockSyncService.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,28 @@ import kotlinx.serialization.encodeToString
3333
internal class MockSyncService(
3434
private val lines: ReceiveChannel<SyncLine>,
3535
) : HttpClientEngineBase("sync-service") {
36-
3736
override val config: HttpClientEngineConfig
3837
get() = Config
3938

40-
override val supportedCapabilities: Set<HttpClientEngineCapability<out Any>> = setOf(
41-
HttpTimeoutCapability,
42-
)
39+
override val supportedCapabilities: Set<HttpClientEngineCapability<out Any>> =
40+
setOf(
41+
HttpTimeoutCapability,
42+
)
4343

4444
@OptIn(InternalAPI::class)
4545
override suspend fun execute(data: HttpRequestData): HttpResponseData {
4646
val context = callContext()
4747
val scope = CoroutineScope(context)
4848

4949
return if (data.url.encodedPath == "/sync/stream") {
50-
val job = scope.writer {
51-
lines.consumeEach {
52-
val serializedLine = JsonUtil.json.encodeToString(it)
53-
channel.writeStringUtf8("$serializedLine\n")
54-
channel.flush()
50+
val job =
51+
scope.writer {
52+
lines.consumeEach {
53+
val serializedLine = JsonUtil.json.encodeToString(it)
54+
channel.writeStringUtf8("$serializedLine\n")
55+
channel.flush()
56+
}
5557
}
56-
}
5758

5859
HttpResponseData(
5960
HttpStatusCode.OK,

0 commit comments

Comments
 (0)