add tests
This commit is contained in:
parent
7590e2df2e
commit
db04735df0
3 changed files with 54 additions and 1 deletions
|
@ -30,7 +30,7 @@ enum class SecretSourceType() {
|
|||
|
||||
|
||||
@Serializable
|
||||
class SecretSupplier(private val source: SecretSourceType, val parameter: String) {
|
||||
data class SecretSupplier(private val source: SecretSourceType, val parameter: String) {
|
||||
fun secret(): Secret {
|
||||
return source.secret(parameter)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package org.domaindrivenarchitecture.provs.server.infrastructure
|
||||
|
||||
import org.domaindrivenarchitecture.provs.configuration.domain.ConfigFileName
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.secret.SecretSourceType
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.secret.SecretSupplier
|
||||
import org.domaindrivenarchitecture.provs.server.domain.k8s_grafana_agent.GrafanaAgentConfig
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class GrafanaAgentRepositoryKtTest {
|
||||
|
||||
@Test
|
||||
fun findK8sGrafanaConfig_returns_config() {
|
||||
// when
|
||||
val config = findK8sGrafanaConfig(ConfigFileName("src/test/resources/k3s-server-config-with-grafana.yaml"))
|
||||
|
||||
// then
|
||||
assertEquals(
|
||||
GrafanaAgentConfig(
|
||||
user = "654321",
|
||||
password = SecretSupplier(SecretSourceType.GOPASS, "path/to/key"),
|
||||
cluster = "myclustername"
|
||||
), config
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findK8sGrafanaConfig_returns_null_if_no_grafan_data_available() {
|
||||
// when
|
||||
val config = findK8sGrafanaConfig(ConfigFileName("src/test/resources/k3sServerConfig.yaml"))
|
||||
|
||||
// then
|
||||
assertEquals(null, config)
|
||||
}
|
||||
}
|
18
src/test/resources/k3s-server-config-with-grafana.yaml
Normal file
18
src/test/resources/k3s-server-config-with-grafana.yaml
Normal file
|
@ -0,0 +1,18 @@
|
|||
fqdn: statistics.test.meissa-gmbh.de
|
||||
node:
|
||||
ipv4: 162.55.164.138
|
||||
ipv6: 2a01:4f8:c010:672f::1
|
||||
certmanager:
|
||||
email: admin@meissa-gmbh.de
|
||||
letsencryptEndpoint: prod
|
||||
echo: true
|
||||
reprovision: true
|
||||
|
||||
|
||||
grafana:
|
||||
user: "654321" # username for the grafana data source
|
||||
password:
|
||||
source: "GOPASS" # PLAIN, GOPASS or PROMPT
|
||||
parameter: "path/to/key" # password of the user or api key
|
||||
cluster: "myclustername" # the cluster name of your choice
|
||||
|
Loading…
Reference in a new issue