-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
86 additions
and
0 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
...ation_embedder/src/test/scala/weco/pipeline/relation_embedder/lib/ConfigurationTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
) | ||
} | ||
} | ||
} |