Skip to content

Commit

Permalink
add config test
Browse files Browse the repository at this point in the history
  • Loading branch information
kenoir committed Dec 19, 2024
1 parent 0477299 commit 4a65af6
Showing 1 changed file with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package weco.pipeline.relation_embedder.lib

import org.scalatest.funspec.AnyFunSpec
import org.scalatest.matchers.should.Matchers
import weco.pipeline.relation_embedder.helpers.ConfigurationTestHelpers

class ConfigurationTest
extends AnyFunSpec
with ConfigurationTestHelpers
with Matchers {

it("loads the base configuration") {
val baseConfig =
"""
|config1 = "value"
|""".asConfig

withLayeredConfig(
baseConfig = baseConfig
) {
config =>
config shouldBe TestAppConfiguration(
config1 = Some("value")
)
}
}

it("overrides the base configuration with the application configuration") {
withLayeredConfig(
baseConfig = """
|config1 = "valueFromBaseForConfig1"
|config2 = "valueFromBaseForConfig2"
|""".asConfig,
applicationConfig = """
|config1 = "valueFromApplicationForConfig1"
|""".asConfig
) {
config =>
config shouldBe TestAppConfiguration(
config1 = Some("valueFromApplicationForConfig1"),
config2 = Some("valueFromBaseForConfig2")
)
}
}

it("overrides the application configuration with the lambda configuration") {
withLayeredConfig(
baseConfig = """
|config1 = "valueFromApplicationForConfig1"
|config2 = "valueFromBaseForConfig2"
|config3 = "valueFromApplicationForConfig3"
|""".asConfig,
applicationConfig = """
|config1 = "valueFromLambdaForConfig1"
|""".asConfig,
lambdaConfig = """
|config1 = "valueFromLambdaForConfig1"
|""".asConfig
) {
config =>
config shouldBe TestAppConfiguration(
config1 = Some("valueFromLambdaForConfig1"),
config2 = Some("valueFromBaseForConfig2"),
config3 = Some("valueFromApplicationForConfig3")
)
}
}

it(
"resolves values in the application config from the lambda configuration"
) {
withLayeredConfig(
applicationConfig = s"""
|config1 = $${?config2}
|""".asConfig,
lambdaConfig = """
|config1 = "valueFromLambdaForConfig2"
|""".asConfig
) {
config =>
config shouldBe TestAppConfiguration(
config1 = Some("valueFromLambdaForConfig2")
)
}
}
}

0 comments on commit 4a65af6

Please sign in to comment.