Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ internal const val MIN_POSTGRES_TOAST_TUPLE_TARGET = 2048

internal const val TRANSACTIONS_COL = Naksha.VIRT_TRANSACTIONS

internal const val NKC_TABLE = Naksha.VIRT_TRANSACTIONS
internal const val NKC_TABLE_ESC = "\"${Naksha.VIRT_TRANSACTIONS}\""
internal const val NKC_TABLE = Naksha.VIRT_COLLECTIONS
internal const val NKC_TABLE_ESC = "\"${Naksha.VIRT_COLLECTIONS}\""
internal const val NKC_PARTITION_COUNT = "partitionCount"
internal const val NKC_ID = "id"
internal const val NKC_GEO_INDEX = "geoIndex"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package naksha.psql

import naksha.model.*
import naksha.model.Action.ActionEnumCompanion.CREATED
import naksha.model.Action.ActionEnumCompanion.DELETED
import naksha.model.objects.NakshaCollection
import naksha.model.objects.NakshaFeature
import naksha.model.request.ReadFeatures
Expand Down Expand Up @@ -38,5 +41,23 @@ class DeleteFeatureTest : PgTestBase(NakshaCollection("delete_feature_test_c"))
})
val responseFeatures = response.features
assertEquals(0, responseFeatures.size)

// verify if history contains 2 versions
val historyResponse = executeRead(ReadFeatures().apply {
collectionIds += collection.id
featureIds += initialFeature.id
queryHistory = true
})
assertEquals(2, historyResponse.features.size)
assertEquals(CREATED, historyResponse.tuples[0]?.tuple?.flags?.actionEnum())
assertEquals(DELETED, historyResponse.tuples[1]?.tuple?.flags?.actionEnum())

// verify if delete table contains element
val deleteTableResponse = executeRead(ReadFeatures().apply {
collectionIds += collection.id
featureIds += initialFeature.id
queryDeleted = true
})
assertEquals(1, deleteTableResponse.features.size)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package naksha.psql

import naksha.model.objects.NakshaCollection
import naksha.model.objects.StoreMode.StoreMode_C.ON
import naksha.model.request.ReadCollections
import naksha.psql.base.PgTestBase
import kotlin.test.AfterTest
import kotlin.test.Test
import kotlin.test.assertEquals

class ReadCollectionsTest : PgTestBase(
collection = NakshaCollection(
id = "read_collections_c",
partitions = 2,
storeDeleted = ON,
storeHistory = ON,
storeMeta = ON,
)
) {

@AfterTest
fun cleanUp() {
dropCollection()
}

@Test
fun shouldReadCollectionMeta() {
// When
val retrievedCollectionMeta = executeRead(ReadCollections().apply {
collectionIds += collection!!.id
})

// Then
assertEquals(1, retrievedCollectionMeta.tuples.size)
val collectionFeature = retrievedCollectionMeta.features[0]!!.proxy(NakshaCollection::class)
assertEquals(collection!!.id, collectionFeature.id)
assertEquals(collection.partitions, collectionFeature.partitions)
assertEquals(collection.storeDeleted, collectionFeature.storeDeleted)
assertEquals(collection.storeMeta, collectionFeature.storeMeta)
assertEquals(collection.storeHistory, collectionFeature.storeHistory)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package naksha.psql

import naksha.model.objects.NakshaCollection
import naksha.model.objects.NakshaFeature
import naksha.model.request.ReadFeatures
import naksha.model.request.Write
import naksha.model.request.WriteRequest
import naksha.psql.base.PgTestBase
import kotlin.test.AfterTest
import kotlin.test.Test
import kotlin.test.assertEquals

class ReadLimitTest : PgTestBase(NakshaCollection("read_limit_test")) {

@AfterTest
fun cleanUp() {
dropCollection()
}

@Test
fun shouldUseLimitWhenReturningResults() {
// Given
val writeReq = WriteRequest().apply {
add(Write().createFeature(null, collection!!.id, NakshaFeature("test_feature1")))
add(Write().createFeature(null, collection.id, NakshaFeature("test_feature2")))
add(Write().createFeature(null, collection.id, NakshaFeature("test_feature3")))
}
executeWrite(writeReq)

// When
val readWithLimit = executeRead(ReadFeatures().apply {
collectionIds += collection!!.id
limit = 2
})

// then
assertEquals(2, readWithLimit.tuples.size)
}
}
Loading
Loading