Skip to content

Commit

Permalink
fix: Realm for unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sirambd committed Oct 10, 2024
1 parent 5427104 commit c565e11
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,27 @@ import kotlin.test.*

class TransferControllerTest {

private val realmProvider = RealmProvider().apply { openRealmTransfers(userId = 0, inMemory = true) }
private val transferController = TransferController(realmProvider)
private lateinit var realmProvider: RealmProvider
private lateinit var transferController: TransferController

@BeforeTest
fun setup() {
realmProvider = RealmProvider().apply { openRealmTransfers(userId = 0, inMemory = true) }
transferController = TransferController(realmProvider)
}

@AfterTest
fun removeData() {
runBlocking { transferController.removeData() }
fun tearDown() = runBlocking {
transferController.removeData()
realmProvider.closeRealmTransfers()
}

@Test
fun canCreateTransfer() = runBlocking {
val transfer = DummyTransfer.transfer
transferController.upsert(transfer)
val realmTransfer = transferController.getTransfer(transfer.linkUuid)
assertNotNull(realmTransfer)
assertNotNull(realmTransfer, "The transfer cannot be null")
assertEquals(transfer.container.uuid, realmTransfer.container?.uuid)
assertEquals(transfer.container.files.count(), realmTransfer.container?.files?.count())
}
Expand Down

0 comments on commit c565e11

Please sign in to comment.