Skip to content

Commit

Permalink
upsert collection test
Browse files Browse the repository at this point in the history
  • Loading branch information
gunplar committed Oct 29, 2024
1 parent d89fe0f commit cecd914
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package naksha.psql
import kotlinx.datetime.Clock
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import naksha.base.Int64
import naksha.base.proxy
import naksha.model.Naksha
import naksha.model.NakshaError
import naksha.model.objects.NakshaCollection
Expand Down Expand Up @@ -264,4 +262,27 @@ class CollectionTests : PgTestBase(collection = null) {
assertEquals(NakshaError.COLLECTION_NOT_FOUND, response.error.code)
assertTrue(response.error.msg.contains(collectionName))
}

@Test
fun shouldUpsertCollection() {
val collectionName = "upsert_collection_test"
val collection = NakshaCollection(id = collectionName)
// create collection using upsert
val response = executeWrite(
WriteRequest().add(
Write().upsertCollection(null, collection)
)
)
val createdCollection = response.features[0]!!.proxy(NakshaCollection::class)
assertEquals(StoreMode.ON, createdCollection.storeDeleted)
collection.storeDeleted = StoreMode.SUSPEND
// update collection using upsert
val updateResponse = executeWrite(
WriteRequest().add(
Write().upsertCollection(null, collection)
)
)
val updatedCollection = updateResponse.features[0]!!.proxy(NakshaCollection::class)
assertEquals(StoreMode.SUSPEND, updatedCollection.storeDeleted)
}
}

0 comments on commit cecd914

Please sign in to comment.