fix problem with potential wrong color due to success not overwritten in logic in printResults

This commit is contained in:
ansgarz 2022-03-19 20:39:31 +01:00
parent 10e5bf933e
commit d2a2ee6b00
4 changed files with 18 additions and 13 deletions

View file

@ -349,18 +349,23 @@ open class Prov protected constructor(
private fun printResults() { private fun printResults() {
println( println(
"============================================== SUMMARY " + (if (instanceName != null) "(" + instanceName + ") " else "") + "============================================== SUMMARY " +
(if (instanceName != null) "(" + instanceName + ") " else "") +
"============================================== " "============================================== "
) )
val successPerLevel = arrayListOf<Boolean>() val successPerLevel = arrayListOf<Boolean>()
for (result in internalResults) { for (result in internalResults) {
val currentLevel = result.level val currentLevel = result.level
// store level result // store level success
val currentLevelSucces = result.provResult?.success ?: false val successOfCurrentLevel = result.provResult?.success ?: false
if (currentLevel >= successPerLevel.size) successPerLevel.add(currentLevelSucces) if (currentLevel < successPerLevel.size) {
successPerLevel[currentLevel] = successOfCurrentLevel
} else {
successPerLevel.add(successOfCurrentLevel)
}
val successOfLevelAbove = if (currentLevel == 0) currentLevelSucces else successPerLevel[currentLevel - 1] val successOfLevelAbove = if (currentLevel == 0) successOfCurrentLevel else successPerLevel[currentLevel - 1]
println(result.toString().escapeControlChars().formattedAsResultLine(successOfLevelAbove)) println(result.toString().escapeControlChars().formattedAsResultLine(successOfLevelAbove))
} }
if (internalResults.size > 1) { if (internalResults.size > 1) {

View file

@ -1,16 +1,15 @@
package org.domaindrivenarchitecture.provs.desktop.infrastructure package org.domaindrivenarchitecture.provs.desktop.infrastructure
import org.domaindrivenarchitecture.provs.test.defaultTestContainer
import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInstall import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInstall
import org.domaindrivenarchitecture.provs.test.tags.ContainerTest import org.domaindrivenarchitecture.provs.test.defaultTestContainer
import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.*
internal class VSCodeKtTest { internal class VSCodeKtTest {
@Test @Test
@ContainerTest @ExtensiveContainerTest
fun provisionAdditionalTools() { fun provisionAdditionalTools() {
// given // given
defaultTestContainer().aptInstall("curl unzip") defaultTestContainer().aptInstall("curl unzip")

View file

@ -11,6 +11,7 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.configureUs
import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.createUser import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.createUser
import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.userExists import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.userExists
import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.userIsInGroupSudo import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.userIsInGroupSudo
import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest
import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -19,7 +20,7 @@ import org.junit.jupiter.api.Test
internal class ProvisionUserKtTest { internal class ProvisionUserKtTest {
@Test @Test
@ContainerTest @ExtensiveContainerTest
fun configureUser() { fun configureUser() {
// given // given
val a = defaultTestContainer() val a = defaultTestContainer()

View file

@ -9,14 +9,14 @@ import org.domaindrivenarchitecture.provs.server.domain.k3s.K3sConfig
import org.domaindrivenarchitecture.provs.server.domain.k3s.Loopback import org.domaindrivenarchitecture.provs.server.domain.k3s.Loopback
import org.domaindrivenarchitecture.provs.server.domain.k3s.Node import org.domaindrivenarchitecture.provs.server.domain.k3s.Node
import org.domaindrivenarchitecture.provs.test.defaultTestContainer import org.domaindrivenarchitecture.provs.test.defaultTestContainer
import org.domaindrivenarchitecture.provs.test.tags.ContainerTest import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest
import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
internal class NetworkKtTest { internal class NetworkKtTest {
@Test @Test
@ContainerTest @ExtensiveContainerTest
fun test_provisionNetwork() { fun test_provisionNetwork() {
// given // given
val p = defaultTestContainer() val p = defaultTestContainer()