File tree Expand file tree Collapse file tree 5 files changed +104
-568
lines changed
commonMain/kotlin/naksha/psql Expand file tree Collapse file tree 5 files changed +104
-568
lines changed Original file line number Diff line number Diff line change @@ -61,8 +61,8 @@ internal const val MIN_POSTGRES_TOAST_TUPLE_TARGET = 2048
6161
6262internal const val TRANSACTIONS_COL = Naksha .VIRT_TRANSACTIONS
6363
64- internal const val NKC_TABLE = Naksha .VIRT_TRANSACTIONS
65- internal const val NKC_TABLE_ESC = " \" ${Naksha .VIRT_TRANSACTIONS } \" "
64+ internal const val NKC_TABLE = Naksha .VIRT_COLLECTIONS
65+ internal const val NKC_TABLE_ESC = " \" ${Naksha .VIRT_COLLECTIONS } \" "
6666internal const val NKC_PARTITION_COUNT = " partitionCount"
6767internal const val NKC_ID = " id"
6868internal const val NKC_GEO_INDEX = " geoIndex"
Original file line number Diff line number Diff line change 11package naksha.psql
22
3+ import naksha.model.*
4+ import naksha.model.Action.ActionEnumCompanion.CREATED
5+ import naksha.model.Action.ActionEnumCompanion.DELETED
36import naksha.model.objects.NakshaCollection
47import naksha.model.objects.NakshaFeature
58import naksha.model.request.ReadFeatures
@@ -38,5 +41,23 @@ class DeleteFeatureTest : PgTestBase(NakshaCollection("delete_feature_test_c"))
3841 })
3942 val responseFeatures = response.features
4043 assertEquals(0 , responseFeatures.size)
44+
45+ // verify if history contains 2 versions
46+ val historyResponse = executeRead(ReadFeatures ().apply {
47+ collectionIds + = collection.id
48+ featureIds + = initialFeature.id
49+ queryHistory = true
50+ })
51+ assertEquals(2 , historyResponse.features.size)
52+ assertEquals(CREATED , historyResponse.tuples[0 ]?.tuple?.flags?.actionEnum())
53+ assertEquals(DELETED , historyResponse.tuples[1 ]?.tuple?.flags?.actionEnum())
54+
55+ // verify if delete table contains element
56+ val deleteTableResponse = executeRead(ReadFeatures ().apply {
57+ collectionIds + = collection.id
58+ featureIds + = initialFeature.id
59+ queryDeleted = true
60+ })
61+ assertEquals(1 , deleteTableResponse.features.size)
4162 }
4263}
Original file line number Diff line number Diff line change 1+ package naksha.psql
2+
3+ import naksha.model.objects.NakshaCollection
4+ import naksha.model.objects.StoreMode.StoreMode_C.ON
5+ import naksha.model.request.ReadCollections
6+ import naksha.psql.base.PgTestBase
7+ import kotlin.test.AfterTest
8+ import kotlin.test.Test
9+ import kotlin.test.assertEquals
10+
11+ class ReadCollectionsTest : PgTestBase (
12+ collection = NakshaCollection (
13+ id = "read_collections_c",
14+ partitions = 2,
15+ storeDeleted = ON ,
16+ storeHistory = ON ,
17+ storeMeta = ON ,
18+ )
19+ ) {
20+
21+ @AfterTest
22+ fun cleanUp () {
23+ dropCollection()
24+ }
25+
26+ @Test
27+ fun shouldReadCollectionMeta () {
28+ // When
29+ val retrievedCollectionMeta = executeRead(ReadCollections ().apply {
30+ collectionIds + = collection!! .id
31+ })
32+
33+ // Then
34+ assertEquals(1 , retrievedCollectionMeta.tuples.size)
35+ val collectionFeature = retrievedCollectionMeta.features[0 ]!! .proxy(NakshaCollection ::class )
36+ assertEquals(collection!! .id, collectionFeature.id)
37+ assertEquals(collection.partitions, collectionFeature.partitions)
38+ assertEquals(collection.storeDeleted, collectionFeature.storeDeleted)
39+ assertEquals(collection.storeMeta, collectionFeature.storeMeta)
40+ assertEquals(collection.storeHistory, collectionFeature.storeHistory)
41+ }
42+ }
Original file line number Diff line number Diff line change 1+ package naksha.psql
2+
3+ import naksha.model.objects.NakshaCollection
4+ import naksha.model.objects.NakshaFeature
5+ import naksha.model.request.ReadFeatures
6+ import naksha.model.request.Write
7+ import naksha.model.request.WriteRequest
8+ import naksha.psql.base.PgTestBase
9+ import kotlin.test.AfterTest
10+ import kotlin.test.Test
11+ import kotlin.test.assertEquals
12+
13+ class ReadLimitTest : PgTestBase (NakshaCollection ("read_limit_test")) {
14+
15+ @AfterTest
16+ fun cleanUp () {
17+ dropCollection()
18+ }
19+
20+ @Test
21+ fun shouldUseLimitWhenReturningResults () {
22+ // Given
23+ val writeReq = WriteRequest ().apply {
24+ add(Write ().createFeature(null , collection!! .id, NakshaFeature (" test_feature1" )))
25+ add(Write ().createFeature(null , collection.id, NakshaFeature (" test_feature2" )))
26+ add(Write ().createFeature(null , collection.id, NakshaFeature (" test_feature3" )))
27+ }
28+ executeWrite(writeReq)
29+
30+ // When
31+ val readWithLimit = executeRead(ReadFeatures ().apply {
32+ collectionIds + = collection!! .id
33+ limit = 2
34+ })
35+
36+ // then
37+ assertEquals(2 , readWithLimit.tuples.size)
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments