[skip ci] updated test

This commit is contained in:
see 2022-06-17 14:35:53 +02:00
parent ce122ac13a
commit b28d03a9e0
2 changed files with 6 additions and 5 deletions

View file

@ -15,7 +15,7 @@ internal fun findSpecConfigFromFile(file: ConfigFileName? = null): Result<Syspec
val filePath = file?.fileName ?: DEFAULT_CONFIG_FILE
if ((filePath == DEFAULT_CONFIG_FILE) && !File(filePath).exists()) {
// use default ide config
findSpecConfigFromResource("syspec/syspec-ide-config.yaml")
return findSpecConfigFromResource("org/domaindrivenarchitecture/provs/syspec/syspec-ide-config.yaml")
}
readFromFile(filePath).yamlToType()
}

View file

@ -8,14 +8,15 @@ import org.junit.jupiter.api.Test
internal class SyspecConfigRepoKtTest {
@Test
fun findSpecConfigFromFile_success() {
fun findSpecConfigFromFile_if_default_file_is_not_found_success() {
// when
@Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") // null would reveal test error
val filePath = javaClass.classLoader.getResource("syspec-config.yaml").file
val res = findSpecConfigFromFile(ConfigFileName(filePath))
val res = findSpecConfigFromFile(ConfigFileName("syspec-config.yaml"))
// then
assertEquals(listOf(CommandSpec("echo just_for_test", "just_for_test")), res.getOrNull()?.command)
assertEquals(
"SyspecConfig(command=[CommandSpec(command=tfenv -h, out=null), CommandSpec(command=python3 --version, out=null), CommandSpec(command=pip3 --version, out=null), CommandSpec(command=terraform --version, out=1.0.8)], file=null, folder=null, host=null, package=[PackageSpec(name=firefox, installed=true), PackageSpec(name=thunderbird, installed=true), PackageSpec(name=ssh, installed=true), PackageSpec(name=git, installed=true), PackageSpec(name=leiningen, installed=true)], netcat=null, socket=null, certificate=null)",
res.getOrNull().toString())
}
@Test