diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Hugo.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Hugo.kt index 7e72075..176219d 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Hugo.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Hugo.kt @@ -76,10 +76,14 @@ fun compareVersions(firstVersion : List<Int>, secondVersion: List<Int>) : String return result } +/** + * Parses hugo version. + * @param hugoVersion can either be version a simple version like "1.22.33" or + * a version string like: hugo v0.126.1-3d40ab+extended linux/amd64 BuildDate=2024-05-15T10:42:34Z VendorInfo=snap:0.126.1 + */ fun getHugoVersionNo(hugoVersion: String) : List<Int> { - // hugo v0.126.1-3d40ab+extended linux/amd64 BuildDate=2024-05-15T10:42:34Z VendorInfo=snap:0.126.1 - var result = hugoVersion.split(" ")[1] + var words = hugoVersion.split(" ") + var result = if (words.size > 1) words[1] else words[0] result = result.split("-")[0].removePrefix("v") return result.split(".").map { it.toInt() } } - diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/HugoTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/HugoTest.kt index 0405f50..c57a931 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/HugoTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/HugoTest.kt @@ -1,7 +1,5 @@ package org.domaindrivenarchitecture.provs.desktop.infrastructure -import org.domaindrivenarchitecture.provs.framework.core.docker.exitAndRmContainer -import org.domaindrivenarchitecture.provs.framework.core.local import org.domaindrivenarchitecture.provs.test.defaultTestContainer import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest import org.junit.jupiter.api.Assertions.assertFalse @@ -12,14 +10,15 @@ internal class HugoTest { @ExtensiveContainerTest fun test_installHugoByDeb() { // given - local().exitAndRmContainer("provs_test") val prov = defaultTestContainer() // when val res = prov.installHugoByDeb() + val res2 = prov.installHugoByDeb() // check idem-potency // then assertTrue(res.success) + assertTrue(res2.success) } @Test