From 75f1521814ea6fe1d5336e75c6c1f74ba151036d Mon Sep 17 00:00:00 2001
From: ansgarz <ansgar.zwick@meissa.de>
Date: Sun, 2 Feb 2025 19:09:57 +0100
Subject: [PATCH] [skip ci] chg Go.kt and GoKtTest.kt & other minor changes

---
 .run/extensive_container_tests_only.run.xml   | 15 ++++++++++
 .../provs/desktop/infrastructure/Go.kt        |  9 ++----
 .../provs/desktop/infrastructure/GoKtTest.kt  | 29 +++++++++++--------
 .../desktop/infrastructure/NpmByNvmKtTest.kt  |  2 +-
 .../ContainerUbuntuHostProcessorTest.kt       |  2 +-
 5 files changed, 37 insertions(+), 20 deletions(-)
 create mode 100644 .run/extensive_container_tests_only.run.xml

diff --git a/.run/extensive_container_tests_only.run.xml b/.run/extensive_container_tests_only.run.xml
new file mode 100644
index 0000000..11c72e3
--- /dev/null
+++ b/.run/extensive_container_tests_only.run.xml
@@ -0,0 +1,15 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="extensive_container_tests_only" type="JUnit" factoryName="JUnit">
+    <module name="provs.test" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
+    <option name="ALTERNATIVE_JRE_PATH" value="17" />
+    <option name="MAIN_CLASS_NAME" value="" />
+    <option name="METHOD_NAME" value="" />
+    <option name="TEST_OBJECT" value="tags" />
+    <option name="VM_PARAMETERS" />
+    <tag value="extensivecontainertest" />
+    <method v="2">
+      <option name="Make" enabled="true" />
+    </method>
+  </configuration>
+</component>
\ No newline at end of file
diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Go.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Go.kt
index b3b37dc..8eab76b 100644
--- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Go.kt
+++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Go.kt
@@ -32,18 +32,15 @@ fun Prov.installGo(
 
     if (result.success) {
         cmd("tar -C /usr/local -xzf $target/go1.23.5.linux-amd64.tar.gz", sudo = true)
+        deleteFile("$target/$filename")
         configureBashForUser()
         createFile("~/.bashrc.d/go.sh", "export PATH=\$PATH:/usr/local/go/bin\n")
-        //cmd(". /usr/local/go/bin/go && go version")
-        // Cross-check if installation was successful
-        deleteFile("$target/$filename")
-        return@taskWithResult ProvResult(checkGoVersion(version))
     } else {
-        return@taskWithResult ProvResult(false, err = "Go $version could not be installed. " + result.err)
+        return@taskWithResult ProvResult(false, err = "Go $version could not be downloaded and installed. " + result.err)
     }
 }
 
-internal fun Prov.checkGoVersion(version: String): Boolean {
+fun Prov.checkGoVersion(version: String): Boolean {
     val installedGoVersion = goVersion()
     return installedGoVersion != null && installedGoVersion.startsWith("go version go" + version)
 }
diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GoKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GoKtTest.kt
index 0ba627d..f6d5df0 100644
--- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GoKtTest.kt
+++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GoKtTest.kt
@@ -1,20 +1,25 @@
 package org.domaindrivenarchitecture.provs.desktop.infrastructure
 
 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
 
 class GoKtTest {
 
-@ContainerTest
- fun installGo() {
- // given
- val container = defaultTestContainer()
-  // when
- val res01 = container.installGo()
- val res02 = container.installGo()
- // then
- assertTrue(res01.success)
- assertTrue(res02.success)
- }
+    @ExtensiveContainerTest
+    fun installGo() {
+        // given
+        val prov = defaultTestContainer()
+
+        // when
+        val res = prov.task {
+            installGo()
+            installGo()  // check repeatability
+            // check if installation was successful
+            cmd("/usr/local/go/bin/go version")
+        }
+
+        // then
+        assertTrue(res.success)
+    }
 }
\ No newline at end of file
diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/NpmByNvmKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/NpmByNvmKtTest.kt
index 3dacbf3..d506c0a 100644
--- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/NpmByNvmKtTest.kt
+++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/NpmByNvmKtTest.kt
@@ -8,7 +8,7 @@ import org.junit.jupiter.api.Assertions.assertTrue
 internal class NpmByNvmKtTest {
 
     @ContainerTest
-    fun installNVMnpm() {
+    fun installNpmByNvm() {
         // given
         val prov = defaultTestContainer()
         prov.aptInstall("curl")
diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/core/processors/ContainerUbuntuHostProcessorTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/core/processors/ContainerUbuntuHostProcessorTest.kt
index 81568f9..4993a6d 100644
--- a/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/core/processors/ContainerUbuntuHostProcessorTest.kt
+++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/core/processors/ContainerUbuntuHostProcessorTest.kt
@@ -30,7 +30,7 @@ class ContainerUbuntuHostProcessorTest {
 
 
     @ExtensiveContainerTest
-    fun test_reopeing_ssh_session_succeeds() {
+    fun test_reopening_ssh_session_succeeds() {
 
         // given
         val containerName = "prov-test-ssh-with-container"