package de.rpr.githubreleases import assertk.assertThat import assertk.assertions.containsExactly import assertk.assertions.containsOnly 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("navidrome", "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 { Config() } } } } })