@@ -12,6 +12,7 @@ import com.powersync.attachments.createAttachmentsTable
12
12
import com.powersync.db.getString
13
13
import com.powersync.db.schema.Schema
14
14
import com.powersync.db.schema.Table
15
+ import com.powersync.testutils.ActiveDatabaseTest
15
16
import com.powersync.testutils.MockedRemoteStorage
16
17
import com.powersync.testutils.UserRow
17
18
import com.powersync.testutils.databaseTest
@@ -27,7 +28,9 @@ import dev.mokkery.spy
27
28
import dev.mokkery.verifySuspend
28
29
import io.kotest.matchers.shouldBe
29
30
import io.kotest.matchers.shouldNotBe
31
+ import kotlinx.coroutines.flow.Flow
30
32
import kotlinx.coroutines.flow.flowOf
33
+ import kotlinx.coroutines.flow.onEach
31
34
import kotlinx.io.files.Path
32
35
import kotlin.test.Test
33
36
import kotlin.time.Duration.Companion.seconds
@@ -53,6 +56,12 @@ class AttachmentsTest {
53
56
)
54
57
}
55
58
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
+
56
65
suspend fun updateSchema (db : PowerSyncDatabase ) {
57
66
db.updateSchema(
58
67
Schema (
@@ -76,11 +85,7 @@ class AttachmentsTest {
76
85
val remote = spy<RemoteStorage >(MockedRemoteStorage ())
77
86
78
87
// 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 )
84
89
85
90
val queue =
86
91
AttachmentQueue (
@@ -188,11 +193,7 @@ class AttachmentsTest {
188
193
val remote = spy<RemoteStorage >(MockedRemoteStorage ())
189
194
190
195
// 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 )
196
197
197
198
val queue =
198
199
AttachmentQueue (
@@ -298,11 +299,7 @@ class AttachmentsTest {
298
299
val remote = spy<RemoteStorage >(MockedRemoteStorage ())
299
300
300
301
// 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 )
306
303
307
304
val queue =
308
305
AttachmentQueue (
@@ -398,11 +395,7 @@ class AttachmentsTest {
398
395
val remote = spy<RemoteStorage >(MockedRemoteStorage ())
399
396
400
397
// 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 )
406
399
407
400
val queue =
408
401
AttachmentQueue (
@@ -513,10 +506,7 @@ class AttachmentsTest {
513
506
}
514
507
515
508
// 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 )
520
510
521
511
val queue =
522
512
AttachmentQueue (
0 commit comments