Skip to content

Commit 250a62d

Browse files
modify refresh dataset test
added tests for refresh dataset for all dataset source types
1 parent a24ee3c commit 250a62d

File tree

1 file changed

+37
-17
lines changed

1 file changed

+37
-17
lines changed

dataset/src/integrationTest/kotlin/com/cosmotech/dataset/service/DatasetServiceIntegrationTest.kt

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -582,24 +582,42 @@ class DatasetServiceIntegrationTest : CsmRedisTestBase() {
582582
}
583583
}
584584

585-
@Test
586-
fun `refresh dataset`() {
587-
organizationSaved =
588-
organizationApiService.registerOrganization(makeOrganization("organization"))
589-
datasetSaved =
590-
datasetApiService.createDataset(
591-
organizationSaved.id!!,
592-
makeDatasetWithRole(sourceType = DatasetSourceType.AzureStorage))
593-
594-
every { eventPublisher.publishEvent(any<TwingraphImportEvent>()) } answers
595-
{
596-
firstArg<TwingraphImportEvent>().response = null
597-
}
585+
@TestFactory
586+
fun `test refreshDataset`() =
587+
mapOf(
588+
DatasetSourceType.AzureStorage to false,
589+
DatasetSourceType.ADT to false,
590+
DatasetSourceType.Twincache to false,
591+
DatasetSourceType.File to true,
592+
DatasetSourceType.None to true)
593+
.map { (source, shouldThrow) ->
594+
DynamicTest.dynamicTest("Test RBAC refreshDataset : $source") {
595+
every { getCurrentAccountIdentifier(any()) } returns CONNECTED_ADMIN_USER
596+
organizationSaved =
597+
organizationApiService.registerOrganization(makeOrganization("organization"))
598+
val parentDataset =
599+
datasetApiService.createDataset(
600+
organizationSaved.id!!, makeDatasetWithRole(sourceType = source))
601+
datasetSaved =
602+
datasetApiService.createDataset(
603+
organizationSaved.id!!,
604+
makeDatasetWithRole(parentId = parentDataset.id!!, sourceType = source))
598605

599-
assertDoesNotThrow {
600-
datasetApiService.refreshDataset(organizationSaved.id!!, datasetSaved.id!!)
601-
}
602-
}
606+
every { eventPublisher.publishEvent(any<TwingraphImportEvent>()) } answers
607+
{
608+
firstArg<TwingraphImportEvent>().response = null
609+
}
610+
if (shouldThrow) {
611+
assertThrows<CsmResourceNotFoundException> {
612+
datasetApiService.refreshDataset(organizationSaved.id!!, datasetSaved.id!!)
613+
}
614+
} else {
615+
assertDoesNotThrow {
616+
datasetApiService.refreshDataset(organizationSaved.id!!, datasetSaved.id!!)
617+
}
618+
}
619+
}
620+
}
603621

604622
@TestFactory
605623
fun `test RBAC twingraphBatchUpdate`() =
@@ -1872,6 +1890,7 @@ class DatasetServiceIntegrationTest : CsmRedisTestBase() {
18721890

18731891
fun makeDatasetWithRole(
18741892
organizationId: String = organizationSaved.id!!,
1893+
parentId: String = "",
18751894
userName: String = TEST_USER_MAIL,
18761895
role: String = ROLE_ADMIN,
18771896
sourceType: DatasetSourceType = DatasetSourceType.File
@@ -1880,6 +1899,7 @@ class DatasetServiceIntegrationTest : CsmRedisTestBase() {
18801899
id = UUID.randomUUID().toString(),
18811900
name = "My datasetRbac",
18821901
organizationId = organizationId,
1902+
parentId = parentId,
18831903
ownerId = "ownerId",
18841904
connector = DatasetConnector(connectorSaved.id!!),
18851905
twingraphId = "graph",

0 commit comments

Comments
 (0)