From 2d1cbcb2f9af226fb0285e10fb9164962eca8cd4 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Tue, 13 Dec 2022 13:14:20 +0100 Subject: [PATCH 1/2] OrtConfigurationTest: Shorten a storage name for a test This also avoids any confusion with the `postgresStorage` property of `ProvenanceStorageConfiguration`. Signed-off-by: Sebastian Schuberth --- model/src/test/kotlin/config/OrtConfigurationTest.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/model/src/test/kotlin/config/OrtConfigurationTest.kt b/model/src/test/kotlin/config/OrtConfigurationTest.kt index 6accf2cd0f29..3c28052f507b 100644 --- a/model/src/test/kotlin/config/OrtConfigurationTest.kt +++ b/model/src/test/kotlin/config/OrtConfigurationTest.kt @@ -242,7 +242,7 @@ class OrtConfigurationTest : WordSpec({ ort: scanner: storages: - postgresStorage: + postgres: connection: url: "postgresql://your-postgresql-server:5444/your-database" schema: public @@ -251,20 +251,20 @@ 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") 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() with(postgresStorage.connection) { username shouldBe "username" From 258b158aa34278e25dc3dd05eb9fd5935f7c22de Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Tue, 13 Dec 2022 13:24:54 +0100 Subject: [PATCH 2/2] OrtConfigurationTest: Extend the prioritization test Also show how to override the password for a `postgresStorage`. Signed-off-by: Sebastian Schuberth --- .../kotlin/config/OrtConfigurationTest.kt | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/model/src/test/kotlin/config/OrtConfigurationTest.kt b/model/src/test/kotlin/config/OrtConfigurationTest.kt index 3c28052f507b..a6ad98fa909c 100644 --- a/model/src/test/kotlin/config/OrtConfigurationTest.kt +++ b/model/src/test/kotlin/config/OrtConfigurationTest.kt @@ -248,10 +248,20 @@ class OrtConfigurationTest : WordSpec({ schema: public username: username password: password + provenanceStorage: + postgresStorage: + connection: + url: "postgresql://your-postgresql-server:5444/your-database" + schema: public + username: username + password: password """.trimIndent() ) - val env = mapOf("ort.scanner.storages.postgres.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( @@ -272,6 +282,16 @@ class OrtConfigurationTest : WordSpec({ password shouldBe "envPassword" } } + + config.scanner.provenanceStorage shouldNotBeNull { + postgresStorage.shouldBeInstanceOf().also { postgresStorage -> + with(postgresStorage.connection) { + username shouldBe "username" + schema shouldBe "public" + password shouldBe "envPassword" + } + } + } } }