diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/install/base/Install.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/install/base/Install.kt index 88bcbea..65f5a03 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/install/base/Install.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/install/base/Install.kt @@ -72,6 +72,14 @@ fun Prov.isPackageInstalled(packageName: String): Boolean { } +/** + * Returns true if a package is installed else false + */ +fun Prov.checkPackageInstalled(packageName: String): ProvResult = taskWithResult { + cmd("dpkg -s $packageName") +} + + /** * Removes a package including its configuration and data file */ diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt index 4381a6b..018a36d 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt @@ -1,6 +1,6 @@ package org.domaindrivenarchitecture.provs.desktop.infrastructure -import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.isPackageInstalled +import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.checkPackageInstalled import org.domaindrivenarchitecture.provs.test.defaultTestContainer import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest import org.junit.jupiter.api.Assertions.assertTrue @@ -9,15 +9,13 @@ internal class FirefoxKtTest { @ExtensiveContainerTest fun installFirefox() { - defaultTestContainer().session { - // when - val res = installFirefox() - - // then - assertTrue(res.success) - - val ffIsInstalled = isPackageInstalled("firefox") - assertTrue(ffIsInstalled) + // when + val result = defaultTestContainer().session { + installFirefox() + checkPackageInstalled("firefox") } + + // then + assertTrue(result.success) } }