Skip to content

Commit 271d392

Browse files
committed
Even more logs
1 parent f2c0035 commit 271d392

File tree

3 files changed

+17
-25
lines changed

3 files changed

+17
-25
lines changed

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

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.powersync.attachments.createAttachmentsTable
1212
import com.powersync.db.getString
1313
import com.powersync.db.schema.Schema
1414
import com.powersync.db.schema.Table
15+
import com.powersync.testutils.ActiveDatabaseTest
1516
import com.powersync.testutils.MockedRemoteStorage
1617
import com.powersync.testutils.UserRow
1718
import com.powersync.testutils.databaseTest
@@ -27,7 +28,9 @@ import dev.mokkery.spy
2728
import dev.mokkery.verifySuspend
2829
import io.kotest.matchers.shouldBe
2930
import io.kotest.matchers.shouldNotBe
31+
import kotlinx.coroutines.flow.Flow
3032
import kotlinx.coroutines.flow.flowOf
33+
import kotlinx.coroutines.flow.onEach
3134
import kotlinx.io.files.Path
3235
import kotlin.test.Test
3336
import kotlin.time.Duration.Companion.seconds
@@ -53,6 +56,12 @@ class AttachmentsTest {
5356
)
5457
}
5558

59+
private fun ActiveDatabaseTest.watchAttachmentsTable(): Flow<List<Attachment>> =
60+
database
61+
.watch("SELECT * FROM attachments") {
62+
Attachment.fromCursor(it)
63+
}.onEach { logger.i { "attachments table results: $it" } }
64+
5665
suspend fun updateSchema(db: PowerSyncDatabase) {
5766
db.updateSchema(
5867
Schema(
@@ -76,11 +85,7 @@ class AttachmentsTest {
7685
val remote = spy<RemoteStorage>(MockedRemoteStorage())
7786

7887
// Monitor the attachments table for testing
79-
val attachmentQuery =
80-
database
81-
// language=SQL
82-
.watch("SELECT * FROM attachments") { Attachment.fromCursor(it) }
83-
.testIn(this)
88+
val attachmentQuery = watchAttachmentsTable().testIn(this)
8489

8590
val queue =
8691
AttachmentQueue(
@@ -188,11 +193,7 @@ class AttachmentsTest {
188193
val remote = spy<RemoteStorage>(MockedRemoteStorage())
189194

190195
// Monitor the attachments table for testing
191-
val attachmentQuery =
192-
database
193-
// language=SQL
194-
.watch("SELECT * FROM attachments") { Attachment.fromCursor(it) }
195-
.testIn(this)
196+
val attachmentQuery = watchAttachmentsTable().testIn(this)
196197

197198
val queue =
198199
AttachmentQueue(
@@ -298,11 +299,7 @@ class AttachmentsTest {
298299
val remote = spy<RemoteStorage>(MockedRemoteStorage())
299300

300301
// Monitor the attachments table for testing
301-
val attachmentQuery =
302-
database
303-
// language=SQL
304-
.watch("SELECT * FROM attachments") { Attachment.fromCursor(it) }
305-
.testIn(this)
302+
val attachmentQuery = watchAttachmentsTable().testIn(this)
306303

307304
val queue =
308305
AttachmentQueue(
@@ -398,11 +395,7 @@ class AttachmentsTest {
398395
val remote = spy<RemoteStorage>(MockedRemoteStorage())
399396

400397
// Monitor the attachments table for testing
401-
val attachmentQuery =
402-
database
403-
// language=SQL
404-
.watch("SELECT * FROM attachments") { Attachment.fromCursor(it) }
405-
.testIn(this)
398+
val attachmentQuery = watchAttachmentsTable().testIn(this)
406399

407400
val queue =
408401
AttachmentQueue(
@@ -513,10 +506,7 @@ class AttachmentsTest {
513506
}
514507

515508
// Monitor the attachments table for testing
516-
val attachmentQuery =
517-
database
518-
.watch("SELECT * FROM attachments") { Attachment.fromCursor(it) }
519-
.testIn(this)
509+
val attachmentQuery = watchAttachmentsTable().testIn(this)
520510

521511
val queue =
522512
AttachmentQueue(

core/src/commonMain/kotlin/com/powersync/attachments/implementation/AttachmentContextImpl.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public open class AttachmentContextImpl(
6666
}
6767

6868
db.writeTransaction { tx ->
69+
logger.v { "saveAttachments($attachments)" }
70+
6971
for (attachment in attachments) {
7072
upsertAttachment(attachment, tx)
7173
}

core/src/commonMain/kotlin/com/powersync/attachments/sync/SyncingService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public open class SyncingService(
7878
merge(
7979
// Handles manual triggers for sync events
8080
syncTriggerFlow.asSharedFlow(),
81-
// Triggers the sync process whenever an underlaying change to the
81+
// Triggers the sync process whenever an underlying change to the
8282
// attachments table happens
8383
attachmentsService
8484
.watchActiveAttachments(),

0 commit comments

Comments
 (0)