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
45 changes: 45 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

language: "en-US"

tone_instructions: >-
Be direct and concise. Skip praise and filler. Focus comments on
correctness, security, and maintainability issues.

early_access: false
enable_free_tier: true

reviews:
profile: "chill" # "chill" or "assertive" — start lenient, tighten later
request_changes_workflow: false
high_level_summary: true
poem: false
review_status: true
collapse_walkthrough: true

auto_review:
enabled: true
drafts: false
labels:
- "!work in progress" # skip PRs labeled "Work in progress"

path_filters:
- "!**/target/**" # sbt build output (root + project/)
- "!**/*.class"
- "!**/*.jar"
- "!**/generated/**"
- "!**/*.lock"

tools:
shellcheck:
enabled: false
markdownlint:
enabled: true
github-checks:
enabled: true
timeout_ms: 90000
languagetool:
enabled: true

chat:
auto_reply: true
46 changes: 17 additions & 29 deletions balta/src/main/scala/za/co/absa/db/balta/DBTestSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

package za.co.absa.db.balta

import org.scalactic.source
import org.scalatest.Tag
import org.scalatest.BeforeAndAfterEach
import org.scalatest.funsuite.AnyFunSuite
import za.co.absa.db.balta.classes.{DBConnection, DBFunction, DBTable, QueryResult}
import za.co.absa.db.balta.classes.DBFunction.DBFunctionWithPositionedParamsOnly
Expand All @@ -36,7 +35,22 @@ import java.util.Properties
* * easy access to DB tables and functions
* * the now() function that returns the current transaction time in the DB
*/
abstract class DBTestSuite(val persistDataOverride: Option[Boolean] = None) extends AnyFunSuite {
abstract class DBTestSuite(val persistDataOverride: Option[Boolean] = None)
extends AnyFunSuite
with BeforeAndAfterEach {

/**
* This to ensure that the tests are idempotent by rolling back the transaction after each test, unless persistData is
* explicitly set to true in the connection info (for rare cases and debugging purposes).
*/
override def afterEach(): Unit = {
if (connectionInfo.persistData) {
dbConnection.connection.commit()
} else {
dbConnection.connection.rollback()
}
super.afterEach()
}

def this(persistDataOverride: Boolean) {
this(Some(persistDataOverride));
Expand All @@ -55,31 +69,6 @@ abstract class DBTestSuite(val persistDataOverride: Option[Boolean] = None) exte
.getOrElse(connectionInfoFromConfig)
}

/**
* This is an enhanced test function that automatically rolls back the transaction after the test is finished
*
* @param testName – the name of the test
* @param testTags – the optional list of tags for this test
* @param testFun – the test function
*/
override protected def test(testName: String, testTags: Tag*)
(testFun: => Any /* Assertion */)
(implicit pos: source.Position): Unit = {
val dbTestFun = {
try {
testFun
}
finally {
if (connectionInfo.persistData) {
dbConnection.connection.commit()
} else {
dbConnection.connection.rollback()
}
}
}
super.test(testName, testTags: _*)(dbTestFun)
}

/**
* This is a helper function that allows to easily access a DB table
* @param tableName - the name of the table
Expand Down Expand Up @@ -175,4 +164,3 @@ object DBTestSuite {
)
}
}

Loading