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"
|
||||||
id "java-test-fixtures"
|
id "java-test-fixtures"
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: "maven-publish"
|
apply plugin: "maven-publish"
|
||||||
|
|
||||||
|
|
||||||
|
version = "0.26.3-SNAPSHOT"
|
||||||
group = "org.domaindrivenarchitecture.provs"
|
group = "org.domaindrivenarchitecture.provs"
|
||||||
version = "0.26.2"
|
|
||||||
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|
|
@ -16,14 +16,21 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.whoami
|
||||||
|
|
||||||
|
|
||||||
internal fun Prov.provisionDesktopCommand(cmd: DesktopCliCommand, conf: DesktopConfig) = task {
|
internal fun Prov.provisionDesktopCommand(cmd: DesktopCliCommand, conf: DesktopConfig) = task {
|
||||||
provisionDesktop(
|
|
||||||
cmd.type,
|
validatePrecondition()
|
||||||
conf.ssh?.keyPair(),
|
|
||||||
conf.gpg?.keyPair(),
|
val only = cmd.onlyModules
|
||||||
conf.gitUserName,
|
if (only == null) {
|
||||||
conf.gitEmail,
|
provisionDesktop(
|
||||||
cmd.onlyModules
|
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,
|
gpg: KeyPair? = null,
|
||||||
gitUserName: String? = null,
|
gitUserName: String? = null,
|
||||||
gitEmail: String? = null,
|
gitEmail: String? = null,
|
||||||
onlyModules: List<String>?
|
|
||||||
) = task {
|
) = 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) {
|
if (desktopType == DesktopType.OFFICE) {
|
||||||
provisionOfficeDesktop()
|
|
||||||
verifyOfficeSetup()
|
verifyOfficeSetup()
|
||||||
}
|
} else if (desktopType == DesktopType.IDE) {
|
||||||
if (desktopType == DesktopType.IDE) {
|
|
||||||
provisionOfficeDesktop()
|
|
||||||
provisionIdeDesktop()
|
|
||||||
verifyIdeSetup()
|
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())
|
val dummyProv = Prov.newInstance(DummyProcessor())
|
||||||
|
|
||||||
mockkObject(Prov)
|
mockkObject(Prov)
|
||||||
every { Prov.newInstance(any(), any(), any(), any(), ) } returns dummyProv
|
every { Prov.newInstance(any(), any(), any(), any()) } returns dummyProv
|
||||||
|
|
||||||
mockkStatic(::local)
|
mockkStatic(::local)
|
||||||
every { local() } returns dummyProv
|
every { local() } returns dummyProv
|
||||||
|
@ -52,7 +52,7 @@ internal class ApplicationKtTest {
|
||||||
every { getConfig("testconfig.yaml") } returns testConfig
|
every { getConfig("testconfig.yaml") } returns testConfig
|
||||||
|
|
||||||
mockkStatic(Prov::provisionDesktop)
|
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,
|
true,
|
||||||
cmd = "mocked command"
|
cmd = "mocked command"
|
||||||
)
|
)
|
||||||
|
@ -85,7 +85,6 @@ internal class ApplicationKtTest {
|
||||||
null,
|
null,
|
||||||
testConfig.gitUserName,
|
testConfig.gitUserName,
|
||||||
testConfig.gitEmail,
|
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."
|
"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", ""))
|
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)
|
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."
|
"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", ""))
|
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)
|
unmockkStatic(::quit)
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@ internal class DesktopServiceKtTest {
|
||||||
DesktopType.BASIC,
|
DesktopType.BASIC,
|
||||||
gitUserName = "testuser",
|
gitUserName = "testuser",
|
||||||
gitEmail = "testuser@test.org",
|
gitEmail = "testuser@test.org",
|
||||||
onlyModules = null
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +53,7 @@ internal class DesktopServiceKtTest {
|
||||||
every { any<Prov>().installPpaFirefox() } returns ProvResult(true, cmd = "mocked")
|
every { any<Prov>().installPpaFirefox() } returns ProvResult(true, cmd = "mocked")
|
||||||
|
|
||||||
// when
|
// when
|
||||||
prov.provisionDesktop(DesktopType.IDE, onlyModules = listOf("firefox"))
|
prov.provisionOnlyModules(DesktopType.IDE, onlyModules = listOf("firefox"))
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verify(exactly = 1) { any<Prov>().installPpaFirefox() }
|
verify(exactly = 1) { any<Prov>().installPpaFirefox() }
|
||||||
|
@ -75,7 +74,7 @@ internal class DesktopServiceKtTest {
|
||||||
every { any<Prov>().provisionBasicDesktop(any(), any(), any(), any()) }
|
every { any<Prov>().provisionBasicDesktop(any(), any(), any(), any()) }
|
||||||
|
|
||||||
// when
|
// when
|
||||||
prov.provisionDesktop(DesktopType.IDE, onlyModules = listOf("verify"))
|
prov.provisionOnlyModules(DesktopType.IDE, onlyModules = listOf("verify"))
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verify(exactly = 1) { any<Prov>().verifyIdeSetup() }
|
verify(exactly = 1) { any<Prov>().verifyIdeSetup() }
|
||||||
|
@ -98,7 +97,7 @@ internal class DesktopServiceKtTest {
|
||||||
every { any<Prov>().provisionBasicDesktop(any(), any(), any(), any()) }
|
every { any<Prov>().provisionBasicDesktop(any(), any(), any(), any()) }
|
||||||
|
|
||||||
// when
|
// when
|
||||||
prov.provisionDesktop(DesktopType.OFFICE, onlyModules = listOf("verify"))
|
prov.provisionOnlyModules(DesktopType.OFFICE, onlyModules = listOf("verify"))
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verify(exactly = 0) { any<Prov>().verifyIdeSetup() }
|
verify(exactly = 0) { any<Prov>().verifyIdeSetup() }
|
||||||
|
@ -122,7 +121,6 @@ internal class DesktopServiceKtTest {
|
||||||
DesktopType.BASIC,
|
DesktopType.BASIC,
|
||||||
gitUserName = "testuser",
|
gitUserName = "testuser",
|
||||||
gitEmail = "testuser@test.org",
|
gitEmail = "testuser@test.org",
|
||||||
onlyModules = null
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
|
@ -147,7 +145,6 @@ internal class DesktopServiceKtTest {
|
||||||
DesktopType.IDE,
|
DesktopType.IDE,
|
||||||
gitUserName = "testuser",
|
gitUserName = "testuser",
|
||||||
gitEmail = "testuser@test.org",
|
gitEmail = "testuser@test.org",
|
||||||
onlyModules = null
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
|
|
Loading…
Reference in a new issue