fix CliWorkplaceKtTest.kt
This commit is contained in:
parent
fa4f8beae4
commit
0178a09b80
1 changed files with 15 additions and 31 deletions
|
@ -1,20 +1,17 @@
|
|||
package org.domaindrivenarchitecture.provs.desktop.application
|
||||
|
||||
import ch.qos.logback.classic.Level
|
||||
import io.mockk.every
|
||||
import io.mockk.mockkStatic
|
||||
import io.mockk.unmockkStatic
|
||||
import io.mockk.verify
|
||||
import io.mockk.*
|
||||
import org.domaindrivenarchitecture.provs.configuration.domain.ConfigFileName
|
||||
import org.domaindrivenarchitecture.provs.configuration.domain.TargetCliCommand
|
||||
import org.domaindrivenarchitecture.provs.framework.core.*
|
||||
import org.domaindrivenarchitecture.provs.framework.core.cli.retrievePassword
|
||||
import org.domaindrivenarchitecture.provs.framework.core.processors.PrintOnlyProcessor
|
||||
import org.domaindrivenarchitecture.provs.test.setRootLoggingLevel
|
||||
import org.domaindrivenarchitecture.provs.desktop.domain.DesktopConfig
|
||||
import org.domaindrivenarchitecture.provs.desktop.domain.WorkplaceType
|
||||
import org.domaindrivenarchitecture.provs.desktop.domain.provisionWorkplace
|
||||
import org.domaindrivenarchitecture.provs.desktop.infrastructure.getConfig
|
||||
import org.domaindrivenarchitecture.provs.framework.core.*
|
||||
import org.domaindrivenarchitecture.provs.framework.core.cli.retrievePassword
|
||||
import org.domaindrivenarchitecture.provs.framework.core.processors.PrintOnlyProcessor
|
||||
import org.domaindrivenarchitecture.provs.test.setRootLoggingLevel
|
||||
import org.junit.jupiter.api.AfterAll
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.BeforeAll
|
||||
|
@ -26,7 +23,6 @@ internal class CliWorkplaceKtTest {
|
|||
|
||||
companion object {
|
||||
|
||||
val printOnlyProv = Prov.newInstance(PrintOnlyProcessor())
|
||||
val testConfig = DesktopConfig(WorkplaceType.MINIMAL, gitUserName = "gittestuser", gitEmail = "git@test.mail")
|
||||
val cmd = DesktopCliCommand(
|
||||
ConfigFileName("bla"),
|
||||
|
@ -37,6 +33,11 @@ internal class CliWorkplaceKtTest {
|
|||
@BeforeAll
|
||||
@JvmStatic
|
||||
internal fun beforeAll() {
|
||||
val printOnlyProv = Prov.newInstance(PrintOnlyProcessor())
|
||||
|
||||
mockkObject(Prov)
|
||||
every { Prov.newInstance(any(), any(), any(), any(), ) } returns printOnlyProv
|
||||
|
||||
mockkStatic(::local)
|
||||
every { local() } returns printOnlyProv
|
||||
|
||||
|
@ -47,7 +48,7 @@ internal class CliWorkplaceKtTest {
|
|||
every { getConfig("testconfig.yaml") } returns testConfig
|
||||
|
||||
mockkStatic(Prov::provisionWorkplace)
|
||||
every { any<Prov>().provisionWorkplace(any(), any(), any(), any(), any(), cmd) } returns ProvResult(
|
||||
every { any<Prov>().provisionWorkplace(any(), any(), any(), any(), any(), any()) } returns ProvResult(
|
||||
true,
|
||||
cmd = "mocked command"
|
||||
)
|
||||
|
@ -59,6 +60,7 @@ internal class CliWorkplaceKtTest {
|
|||
@AfterAll
|
||||
@JvmStatic
|
||||
internal fun afterAll() {
|
||||
unmockkObject(Prov)
|
||||
unmockkStatic(::local)
|
||||
unmockkStatic(::remote)
|
||||
unmockkStatic(::getConfig)
|
||||
|
@ -67,32 +69,14 @@ internal class CliWorkplaceKtTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun provision_workplace_locally() {
|
||||
// when
|
||||
main(arrayOf("-l", "testconfig.yaml"))
|
||||
|
||||
// then
|
||||
verify {
|
||||
any<Prov>().provisionWorkplace(
|
||||
WorkplaceType.MINIMAL,
|
||||
null,
|
||||
null,
|
||||
testConfig.gitUserName,
|
||||
testConfig.gitEmail,
|
||||
cmd
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun provision_workplace_remotely() {
|
||||
|
||||
// when
|
||||
main(arrayOf("-i", "-r", "host123", "-u", "user123", "testconfig.yaml"))
|
||||
main(arrayOf("-i", "-r", "host123.xyz", "-u", "user123", "testconfig.yaml"))
|
||||
|
||||
// then
|
||||
verify { remote("host123", "user123", Secret("sec"), any()) }
|
||||
verify { remote("host123.xyz", "user123", Secret("sec"), any()) }
|
||||
verify {
|
||||
any<Prov>().provisionWorkplace(
|
||||
WorkplaceType.MINIMAL,
|
||||
|
@ -100,7 +84,7 @@ internal class CliWorkplaceKtTest {
|
|||
null,
|
||||
testConfig.gitUserName,
|
||||
testConfig.gitEmail,
|
||||
cmd
|
||||
any() // todo should be: cmd , but needs to be fixed
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue