50 lines
No EOL
1.7 KiB
Kotlin
50 lines
No EOL
1.7 KiB
Kotlin
package de.rpr.githubreleases
|
|
|
|
import assertk.assertThat
|
|
import assertk.assertions.containsExactly
|
|
import assertk.assertions.containsOnly
|
|
import de.rpr.githubreleases.model.GithubRepo
|
|
import io.kotest.core.spec.style.DescribeSpec
|
|
import io.kotest.extensions.system.withEnvironment
|
|
import org.junit.jupiter.api.assertThrows
|
|
|
|
class ConfigTest : DescribeSpec({
|
|
|
|
describe("instantiation") {
|
|
|
|
withEnvironment(
|
|
mapOf(
|
|
"GITHUB_REPOS" to "https://github.com/navidrome/navidrome/",
|
|
"NAVIDROME_MASTODON_INSTANCE_URL" to "example.com",
|
|
"NAVIDROME_MASTODON_ACCESS_TOKEN" to "token"
|
|
)
|
|
) {
|
|
|
|
it("should populate instances from config") {
|
|
val config = Config()
|
|
assertThat(config.githubRepos).containsExactly(
|
|
GithubRepo("https://github.com/navidrome/navidrome/")
|
|
)
|
|
assertThat(config.mastodonCredentials).containsOnly(
|
|
"navidrome" to Config.PublishingCredentials(
|
|
instanceUrl = "example.com",
|
|
accessToken = "token",
|
|
instanceUrlEnvName = "NAVIDROME_MASTODON_INSTANCE_URL",
|
|
accessTokenEnvName = "NAVIDROME_MASTODON_ACCESS_TOKEN"
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
withEnvironment(
|
|
mapOf("GITHUB_REPOS" to "https://github.com/navidrome/navidrome/")
|
|
) {
|
|
|
|
it("should throw error if env variables for repo are not present") {
|
|
assertThrows<IllegalStateException> {
|
|
Config()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}) |