Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feaature/43 release notes checker fix #50

Closed
wants to merge 6 commits into from
Closed
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
5 changes: 4 additions & 1 deletion .github/workflows/check_pr_release_notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ jobs:
if: steps.pr_info.outputs.skip_check == 'false'
run: |
# Extract the body from the previous step
PR_BODY="${{ steps.pr_info.outputs.pr_body }}"
PR_BODY=$(cat <<-'EOF'
${{ steps.pr_info.outputs.pr_body }}
EOF
)

# Check if "Release Notes:" exists
if ! echo "$PR_BODY" | grep -q '${{ env.RLS_NOTES_TAG_REGEX }}'; then
Expand Down
20 changes: 17 additions & 3 deletions balta/src/main/scala/za/co/absa/db/balta/DBTestSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ 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 extends AnyFunSuite {
abstract class DBTestSuite(val persistDataOverride: Option[Boolean] = None) extends AnyFunSuite {

def this(persistDataOverride: Boolean) {
this(Some(persistDataOverride));
}

/* the DB connection is ``lazy`, so it actually can be created only when needed and therefore the credentials
overridden in the successor */
Expand All @@ -44,7 +48,11 @@ abstract class DBTestSuite extends AnyFunSuite {
/**
* This is the connection info for the DB. It can be overridden in the derived classes to provide specific credentials
*/
protected lazy val connectionInfo: ConnectionInfo = readConnectionInfoFromConfig
protected lazy val connectionInfo: ConnectionInfo = {
val connectionInfoFromConfig = readConnectionInfoFromConfig
persistDataOverride.map(overrideValue => connectionInfoFromConfig.copy(persistData = overrideValue))
.getOrElse(connectionInfoFromConfig)
}

/**
* This is an enhanced test function that automatically rolls back the transaction after the test is finished
Expand Down Expand Up @@ -147,8 +155,14 @@ abstract class DBTestSuite extends AnyFunSuite {

// private functions
private def readConnectionInfoFromConfig: ConnectionInfo = {
DBTestSuite.connectionInfoFromResourceConfig("/database.properties")
}
}

object DBTestSuite {
def connectionInfoFromResourceConfig(resourceName: String): ConnectionInfo = {
val properties = new Properties()
properties.load(getClass.getResourceAsStream("/database.properties"))
properties.load(getClass.getResourceAsStream(resourceName))

ConnectionInfo(
dbUrl = properties.getProperty("test.jdbc.url"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2023 ABSA Group Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package za.co.absa.db.balta

import org.scalatest.funsuite.AnyFunSuiteLike

class DBTestSuiteUnitTests extends AnyFunSuiteLike {
test("connectionInfoFromResourceConfig reads local resource file correctly") {
val connectionInfo = DBTestSuite.connectionInfoFromResourceConfig("/database.properties")
assert(connectionInfo.dbUrl == "jdbc:postgresql://localhost:5432/mag_db")
assert(connectionInfo.username == "mag_owner")
assert(connectionInfo.password == "changeme")
assert(!connectionInfo.persistData)
}
}
Loading