-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow data class with one field to be considered a value type #164
- Loading branch information
Showing
3 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
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
19 changes: 19 additions & 0 deletions
19
hoplite-yaml/src/test/kotlin/com/sksamuel/hoplite/yaml/ValueTypeDecoderTest.kt
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,19 @@ | ||
package com.sksamuel.hoplite.yaml | ||
|
||
import com.sksamuel.hoplite.ConfigLoader | ||
import io.kotest.core.spec.style.StringSpec | ||
import io.kotest.matchers.shouldBe | ||
|
||
class ValueTypeDecoderTest : StringSpec({ | ||
"single value field as value type" { | ||
|
||
// host.value doesn't exist in the config, but because it is a value type, the value of "host" | ||
// will be used instead | ||
data class Host(val value: String) | ||
data class Server(val host: Host) | ||
data class Config(val server: Server) | ||
|
||
val config = ConfigLoader().loadConfigOrThrow<Config>("/value_type.yml") | ||
config shouldBe Config(Server(Host("localhost"))) | ||
} | ||
}) |
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,2 @@ | ||
server: | ||
host: localhost |