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

Minor OrtConfigurationTest improvements #6226

Merged
merged 2 commits into from Dec 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 24 additions & 4 deletions model/src/test/kotlin/config/OrtConfigurationTest.kt
Expand Up @@ -242,6 +242,13 @@ class OrtConfigurationTest : WordSpec({
ort:
scanner:
storages:
postgres:
connection:
url: "postgresql://your-postgresql-server:5444/your-database"
schema: public
username: username
password: password
provenanceStorage:
postgresStorage:
connection:
url: "postgresql://your-postgresql-server:5444/your-database"
Expand All @@ -251,27 +258,40 @@ class OrtConfigurationTest : WordSpec({
""".trimIndent()
)

val env = mapOf("ort.scanner.storages.postgresStorage.connection.password" to "envPassword")
val env = mapOf(
"ort.scanner.storages.postgres.connection.password" to "envPassword",
"ort.scanner.provenanceStorage.postgresStorage.connection.password" to "envPassword"
)

withEnvironment(env) {
val config = OrtConfiguration.load(
args = mapOf(
"ort.scanner.storages.postgresStorage.connection.schema" to "argsSchema",
"ort.scanner.storages.postgresStorage.connection.password" to "argsPassword",
"ort.scanner.storages.postgres.connection.schema" to "argsSchema",
"ort.scanner.storages.postgres.connection.password" to "argsPassword",
"other.property" to "someValue"
),
file = configFile
)

config.scanner.storages shouldNotBeNull {
val postgresStorage = this["postgresStorage"]
val postgresStorage = this["postgres"]
postgresStorage.shouldBeInstanceOf<PostgresStorageConfiguration>()
with(postgresStorage.connection) {
username shouldBe "username"
schema shouldBe "argsSchema"
password shouldBe "envPassword"
}
}

config.scanner.provenanceStorage shouldNotBeNull {
postgresStorage.shouldBeInstanceOf<PostgresStorageConfiguration>().also { postgresStorage ->
with(postgresStorage.connection) {
username shouldBe "username"
schema shouldBe "public"
password shouldBe "envPassword"
}
}
}
}
}

Expand Down