Skip to content
Snippets Groups Projects
Commit 57d36af8 authored by Sebastian's avatar Sebastian
Browse files

Add database test with settings

parent 34794283
No related branches found
No related tags found
1 merge request!20Remove DatabaseComponent and use Database directly
...@@ -2,6 +2,7 @@ package org.briarproject.mailbox.core.db ...@@ -2,6 +2,7 @@ package org.briarproject.mailbox.core.db
import org.briarproject.mailbox.core.TestUtils.deleteTestDirectory import org.briarproject.mailbox.core.TestUtils.deleteTestDirectory
import org.briarproject.mailbox.core.api.Contact import org.briarproject.mailbox.core.api.Contact
import org.briarproject.mailbox.core.settings.Settings
import org.briarproject.mailbox.core.system.Clock import org.briarproject.mailbox.core.system.Clock
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir import org.junit.jupiter.api.io.TempDir
...@@ -85,4 +86,31 @@ abstract class JdbcDatabaseTest { ...@@ -85,4 +86,31 @@ abstract class JdbcDatabaseTest {
db.close() db.close()
} }
@Test
@Throws(java.lang.Exception::class)
open fun testMergeSettings() {
val before = Settings()
before["foo"] = "bar"
before["baz"] = "bam"
val update = Settings()
update["baz"] = "qux"
val merged = Settings()
merged["foo"] = "bar"
merged["baz"] = "qux"
var db: Database = open(false)
var txn = db.startTransaction()
// store 'before'
db.mergeSettings(txn, before, "namespace")
assertEquals(before, db.getSettings(txn, "namespace"))
// merge 'update'
db.mergeSettings(txn, update, "namespace")
assertEquals(merged, db.getSettings(txn, "namespace"))
db.commitTransaction(txn)
db.close()
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment