Skip to content

Commit

Permalink
Adding circe as test dependency and refining test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
TebaleloS committed Aug 15, 2024
1 parent 1416d54 commit 08b9ff9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package za.co.absa.atum.database.runs

import za.co.absa.balta.DBTestSuite
import za.co.absa.balta.classes.JsonBString
import io.circe.Json
import io.circe.parser._

class GetPartitioningByIdIntegrationTests extends DBTestSuite {

Expand All @@ -38,6 +40,11 @@ class GetPartitioningByIdIntegrationTests extends DBTestSuite {
|""".stripMargin
)

private val expectedPartitioning: Json = parse(partitioning.value) match {
case Right(json) => json
case Left(error) => throw new Exception(s"Failed to parse JSON: ${error.getMessage}")
}

test("Partitioning retrieved successfully") {
table("runs.partitionings").insert(
add("partitioning", partitioning)
Expand All @@ -51,16 +58,20 @@ class GetPartitioningByIdIntegrationTests extends DBTestSuite {
.execute { queryResult =>
assert(queryResult.hasNext)
val row = queryResult.next()
val returnedPartitioning = row.getJsonB("partitioning").get
val returnedPartitioningParsed = parse(returnedPartitioning.value).getOrElse(Json.Null)
assert(row.getInt("status").contains(11))
assert(row.getString("status_text").contains("OK"))
assert(row.getLong("id").contains(fkPartitioning1))
assert(row.getJsonB("partitioning").isDefined) // Todo: Check the actual value
assert(returnedPartitioningParsed == expectedPartitioning)
assert(row.getString("author").contains("Joseph"))
}

table("runs.partitionings").where(add("id_partitioning", fkPartitioning1)) { partitioningResult =>
val row = partitioningResult.next()
assert(row.getJsonB("partitioning").isDefined) // Todo: check the actual value
val returnedPartitioning = row.getJsonB("partitioning").get
val returnedPartitioningParsed = parse(returnedPartitioning.value).getOrElse(Json.Null)
assert(returnedPartitioningParsed == expectedPartitioning)
assert(row.getString("created_by").contains("Joseph"))
}
}
Expand Down
8 changes: 6 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,16 @@ object Dependencies {
}

def databaseDependencies: Seq[ModuleID] = {
lazy val scalaTest = "org.scalatest" %% "scalatest" % Versions.scalatest % Test
lazy val balta = "za.co.absa" %% "balta" % Versions.balta % Test
lazy val scalaTest = "org.scalatest" %% "scalatest" % Versions.scalatest % Test
lazy val balta = "za.co.absa" %% "balta" % Versions.balta % Test
lazy val circe = "io.circe" %% "circe-core" % Versions.circeJson % Test
lazy val parser = "io.circe" %% "circe-parser" % Versions.circeJson % Test

Seq(
scalaTest,
balta,
circe,
parser,
)
}

Expand Down

0 comments on commit 08b9ff9

Please sign in to comment.