further refactor onlyModules
This commit is contained in:
parent
3b18318921
commit
17d3eb3491
4 changed files with 45 additions and 41 deletions
|
@ -13,12 +13,11 @@ plugins {
|
|||
id "java"
|
||||
id "java-test-fixtures"
|
||||
}
|
||||
|
||||
apply plugin: "maven-publish"
|
||||
|
||||
|
||||
version = "0.26.3-SNAPSHOT"
|
||||
group = "org.domaindrivenarchitecture.provs"
|
||||
version = "0.26.2"
|
||||
|
||||
|
||||
repositories {
|
||||
|
|
|
@ -16,14 +16,21 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.whoami
|
|||
|
||||
|
||||
internal fun Prov.provisionDesktopCommand(cmd: DesktopCliCommand, conf: DesktopConfig) = task {
|
||||
provisionDesktop(
|
||||
cmd.type,
|
||||
conf.ssh?.keyPair(),
|
||||
conf.gpg?.keyPair(),
|
||||
conf.gitUserName,
|
||||
conf.gitEmail,
|
||||
cmd.onlyModules
|
||||
)
|
||||
|
||||
validatePrecondition()
|
||||
|
||||
val only = cmd.onlyModules
|
||||
if (only == null) {
|
||||
provisionDesktop(
|
||||
cmd.type,
|
||||
conf.ssh?.keyPair(),
|
||||
conf.gpg?.keyPair(),
|
||||
conf.gitUserName,
|
||||
conf.gitEmail,
|
||||
)
|
||||
} else {
|
||||
provisionOnlyModules(cmd.type, only)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,33 +48,35 @@ internal fun Prov.provisionDesktop(
|
|||
gpg: KeyPair? = null,
|
||||
gitUserName: String? = null,
|
||||
gitEmail: String? = null,
|
||||
onlyModules: List<String>?
|
||||
) = task {
|
||||
validatePrecondition()
|
||||
|
||||
if (onlyModules == null) {
|
||||
provisionBasicDesktop(gpg, ssh, gitUserName, gitEmail)
|
||||
provisionBasicDesktop(gpg, ssh, gitUserName, gitEmail)
|
||||
|
||||
if (desktopType == DesktopType.OFFICE) {
|
||||
provisionOfficeDesktop()
|
||||
verifyOfficeSetup()
|
||||
}
|
||||
if (desktopType == DesktopType.IDE) {
|
||||
provisionOfficeDesktop()
|
||||
provisionIdeDesktop()
|
||||
verifyIdeSetup()
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Prov.provisionOnlyModules(
|
||||
desktopType: DesktopType = DesktopType.BASIC,
|
||||
onlyModules: List<String>
|
||||
) = task {
|
||||
|
||||
if (FIREFOX.isIn(onlyModules)) {
|
||||
installPpaFirefox()
|
||||
}
|
||||
if (VERIFY.isIn(onlyModules)) {
|
||||
if (desktopType == DesktopType.OFFICE) {
|
||||
provisionOfficeDesktop()
|
||||
verifyOfficeSetup()
|
||||
}
|
||||
if (desktopType == DesktopType.IDE) {
|
||||
provisionOfficeDesktop()
|
||||
provisionIdeDesktop()
|
||||
} else if (desktopType == DesktopType.IDE) {
|
||||
verifyIdeSetup()
|
||||
}
|
||||
} else {
|
||||
if (FIREFOX.isIn(onlyModules)) {
|
||||
installPpaFirefox()
|
||||
}
|
||||
if (VERIFY.isIn(onlyModules)) {
|
||||
if (desktopType == DesktopType.OFFICE) {
|
||||
verifyOfficeSetup()
|
||||
} else if (desktopType == DesktopType.IDE) {
|
||||
verifyIdeSetup()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ internal class ApplicationKtTest {
|
|||
val dummyProv = Prov.newInstance(DummyProcessor())
|
||||
|
||||
mockkObject(Prov)
|
||||
every { Prov.newInstance(any(), any(), any(), any(), ) } returns dummyProv
|
||||
every { Prov.newInstance(any(), any(), any(), any()) } returns dummyProv
|
||||
|
||||
mockkStatic(::local)
|
||||
every { local() } returns dummyProv
|
||||
|
@ -52,7 +52,7 @@ internal class ApplicationKtTest {
|
|||
every { getConfig("testconfig.yaml") } returns testConfig
|
||||
|
||||
mockkStatic(Prov::provisionDesktop)
|
||||
every { any<Prov>().provisionDesktop(any(), any(), any(), any(), any(),any()) } returns ProvResult(
|
||||
every { any<Prov>().provisionDesktop(any(), any(), any(), any(), any()) } returns ProvResult(
|
||||
true,
|
||||
cmd = "mocked command"
|
||||
)
|
||||
|
@ -85,7 +85,6 @@ internal class ApplicationKtTest {
|
|||
null,
|
||||
testConfig.gitUserName,
|
||||
testConfig.gitEmail,
|
||||
null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +118,7 @@ internal class ApplicationKtTest {
|
|||
"Error: File\u001B[31m idontexist.yaml \u001B[0m was not found.Pls copy file \u001B[31m desktop-config-example.yaml \u001B[0m to file \u001B[31m idontexist.yaml \u001B[0m and change the content according to your needs.No suitable config found."
|
||||
assertEquals(expectedOutput, outContent.toString().replace("\r", "").replace("\n", ""))
|
||||
|
||||
verify(exactly = 0) { any<Prov>().provisionDesktop(any(), any(), any(), any(), any(), any()) }
|
||||
verify(exactly = 0) { any<Prov>().provisionDesktop(any(), any(), any(), any(), any()) }
|
||||
|
||||
unmockkStatic(::quit)
|
||||
}
|
||||
|
@ -153,7 +152,7 @@ internal class ApplicationKtTest {
|
|||
"Error: File \"src/test/resources/invalid-desktop-config.yaml\" has an invalid format and or invalid data.No suitable config found."
|
||||
assertEquals(expectedOutput, outContent.toString().replace("\r", "").replace("\n", ""))
|
||||
|
||||
verify(exactly = 0) { any<Prov>().provisionDesktop(any(), any(), any(), any(), any(), any()) }
|
||||
verify(exactly = 0) { any<Prov>().provisionDesktop(any(), any(), any(), any(), any()) }
|
||||
|
||||
unmockkStatic(::quit)
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ internal class DesktopServiceKtTest {
|
|||
DesktopType.BASIC,
|
||||
gitUserName = "testuser",
|
||||
gitEmail = "testuser@test.org",
|
||||
onlyModules = null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +53,7 @@ internal class DesktopServiceKtTest {
|
|||
every { any<Prov>().installPpaFirefox() } returns ProvResult(true, cmd = "mocked")
|
||||
|
||||
// when
|
||||
prov.provisionDesktop(DesktopType.IDE, onlyModules = listOf("firefox"))
|
||||
prov.provisionOnlyModules(DesktopType.IDE, onlyModules = listOf("firefox"))
|
||||
|
||||
// then
|
||||
verify(exactly = 1) { any<Prov>().installPpaFirefox() }
|
||||
|
@ -75,7 +74,7 @@ internal class DesktopServiceKtTest {
|
|||
every { any<Prov>().provisionBasicDesktop(any(), any(), any(), any()) }
|
||||
|
||||
// when
|
||||
prov.provisionDesktop(DesktopType.IDE, onlyModules = listOf("verify"))
|
||||
prov.provisionOnlyModules(DesktopType.IDE, onlyModules = listOf("verify"))
|
||||
|
||||
// then
|
||||
verify(exactly = 1) { any<Prov>().verifyIdeSetup() }
|
||||
|
@ -98,7 +97,7 @@ internal class DesktopServiceKtTest {
|
|||
every { any<Prov>().provisionBasicDesktop(any(), any(), any(), any()) }
|
||||
|
||||
// when
|
||||
prov.provisionDesktop(DesktopType.OFFICE, onlyModules = listOf("verify"))
|
||||
prov.provisionOnlyModules(DesktopType.OFFICE, onlyModules = listOf("verify"))
|
||||
|
||||
// then
|
||||
verify(exactly = 0) { any<Prov>().verifyIdeSetup() }
|
||||
|
@ -122,7 +121,6 @@ internal class DesktopServiceKtTest {
|
|||
DesktopType.BASIC,
|
||||
gitUserName = "testuser",
|
||||
gitEmail = "testuser@test.org",
|
||||
onlyModules = null
|
||||
)
|
||||
|
||||
// then
|
||||
|
@ -147,7 +145,6 @@ internal class DesktopServiceKtTest {
|
|||
DesktopType.IDE,
|
||||
gitUserName = "testuser",
|
||||
gitEmail = "testuser@test.org",
|
||||
onlyModules = null
|
||||
)
|
||||
|
||||
// then
|
||||
|
|
Loading…
Reference in a new issue