replace assert in tests with junit assertTrue

This commit is contained in:
ansgarz 2022-04-18 19:15:58 +02:00
parent 22018a141f
commit ef56118ccb
8 changed files with 45 additions and 47 deletions

View file

@ -5,7 +5,7 @@
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="tags" />
<option name="VM_PARAMETERS" value="-DexcludeTags=&quot;containertest&quot;" />
<option name="VM_PARAMETERS" />
<tag value="!containertest" />
<method v="2">
<option name="Make" enabled="true" />

View file

@ -15,11 +15,11 @@ import java.io.PrintStream
internal class ProvTest {
private fun Prov.task_returningFalse() = task {
private fun Prov.task_returningFalse() = taskWithResult {
ProvResult(false)
}
private fun Prov.task_returningTrue() = task {
private fun Prov.task_returningTrue() = taskWithResult {
ProvResult(true)
}
@ -30,7 +30,7 @@ internal class ProvTest {
val res = Prov.newInstance(name = "testing").cmd("echo --testing--").success
// then
assert(res)
assertTrue(res)
}
@Test
@ -49,7 +49,7 @@ internal class ProvTest {
val res = Prov.newInstance(name = "testing").sh(script).success
// then
assert(res)
assertTrue(res)
}
@Test
@ -70,7 +70,7 @@ internal class ProvTest {
val res = Prov.newInstance(name = "provs_test").sh(script, "/root", true).success
// then
assert(res)
assertTrue(res)
}
@Test
@ -86,7 +86,7 @@ internal class ProvTest {
val res = testLocal().tst_task().success
// then
assert(res)
assertTrue(res)
}
@Test
@ -101,7 +101,7 @@ internal class ProvTest {
val res = testLocal().tst_task().success
// then
assert(res)
assertTrue(res)
}
@Test
@ -116,7 +116,7 @@ internal class ProvTest {
val res = testLocal().tst_task().success
// then
assert(!res)
assertFalse(res)
}
@Test
@ -131,7 +131,7 @@ internal class ProvTest {
val res = testLocal().tst_task_all_true_mode_ALL().success
// then
assert(res)
assertTrue(res)
}
// given
@ -147,7 +147,7 @@ internal class ProvTest {
val res = testLocal().tst_task_one_false_mode_ALL().success
// then
assert(!res)
assertFalse(res)
}
// given
@ -169,7 +169,7 @@ internal class ProvTest {
val res = testLocal().tst_task_one_false_mode_ALL_nested().success
// then
assert(!res)
assertFalse(res)
}
@Test
@ -189,7 +189,7 @@ internal class ProvTest {
val res = testLocal().tst_task_one_false_mode_ALL().success
// then
assert(!res)
assertFalse(res)
}
@Test
@ -209,7 +209,7 @@ internal class ProvTest {
val res = testLocal().tst_task_failexit_outer().success
// then
assert(!res)
assertFalse(res)
}
@Test
@ -229,7 +229,7 @@ internal class ProvTest {
val res = testLocal().tst_task_failexit_outer().success
// then
assert(res)
assertTrue(res)
}
@Test
@ -254,7 +254,7 @@ internal class ProvTest {
val res = testLocal().tst_nested().success
// then
assert(!res)
assertFalse(res)
}

View file

@ -11,8 +11,7 @@ import org.domaindrivenarchitecture.provs.test.tags.ContainerTest
import org.domaindrivenarchitecture.provs.test.tags.NonCi
import org.domaindrivenarchitecture.provs.test.testDockerWithSudo
import org.domaindrivenarchitecture.provs.test.testLocal
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
internal class UbuntuProvTest {
@ -28,9 +27,9 @@ internal class UbuntuProvTest {
val res2 = a.cmd("echo abc", dir)
// then
assert(res1.success)
assert(res2.success)
assert(res2.out?.trim() == "abc")
assertTrue(res1.success)
assertTrue(res2.success)
assertTrue(res2.out?.trim() == "abc")
}
@Test
@ -43,8 +42,8 @@ internal class UbuntuProvTest {
val res1 = a.cmd("echo abc", "/root", sudo = true)
// then
assert(res1.success)
assert(res1.out?.trim() == "abc")
assertTrue(res1.success)
assertTrue(res1.out?.trim() == "abc")
}
@Test
@ -58,9 +57,9 @@ internal class UbuntuProvTest {
val res2 = a.cmd("echo abc", dir)
// then
assert(res1.success)
assert(res2.success)
assert(res2.out?.trim() == "abc")
assertTrue(res1.success)
assertTrue(res2.success)
assertTrue(res2.out?.trim() == "abc")
}
@Test
@ -73,10 +72,10 @@ internal class UbuntuProvTest {
val res2 = a.exec("/bin/bash", "-c", "echo echoed")
// then
assert(res1.success)
assert(res1.out?.trim() == "hi")
assert(res2.success)
assert(res2.out?.trim() == "echoed")
assertTrue(res1.success)
assertTrue(res1.out?.trim() == "hi")
assertTrue(res2.success)
assertTrue(res2.out?.trim() == "echoed")
}
@Test

View file

@ -4,9 +4,8 @@ import org.domaindrivenarchitecture.provs.framework.core.newline
import org.domaindrivenarchitecture.provs.test.defaultTestContainer
import org.domaindrivenarchitecture.provs.test.tags.ContainerTest
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.condition.EnabledOnOs
import org.junit.jupiter.api.condition.OS
internal class ContainerProcessorTest {
@ -22,7 +21,7 @@ internal class ContainerProcessorTest {
val res = prov.cmd("echo '${text}'")
// then
assert(res.success)
assertTrue(res.success)
assertEquals(text + newline(), res.out)
}
@ -38,7 +37,7 @@ internal class ContainerProcessorTest {
val res = prov.cmdNoLog("echo '${text}'")
// then
assert(res.success)
assertTrue(res.success)
assertEquals(text + newline(), res.out)
// todo add check that cmd was not logged

View file

@ -4,8 +4,7 @@ import org.domaindrivenarchitecture.provs.framework.core.Prov
import org.domaindrivenarchitecture.provs.framework.core.escapeAndEncloseByDoubleQuoteForShell
import org.domaindrivenarchitecture.provs.framework.core.escapeProcentForPrintf
import org.domaindrivenarchitecture.provs.framework.core.escapeSingleQuoteForShell
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
@ -21,8 +20,8 @@ internal class LocalProcessorTest {
val res = prov.cmd("printf '${text.replace("%", "%%").escapeSingleQuoteForShell()}'")
// then
assert(res.success)
assert(res.out == text)
assertTrue(res.success)
assertTrue(res.out == text)
}
@ -52,7 +51,7 @@ internal class LocalProcessorTest {
val res = prov.cmdNoLog("echo $osSpecificText")
// then
assert(res.success)
assertTrue(res.success)
assertEquals( text + System.lineSeparator(), res.out)
// todo add check that cmd was not logged
@ -68,8 +67,8 @@ internal class LocalProcessorTest {
val res = prov.cmd("iamanunknowncmd")
// then
assert(!res.success)
assert(res.out.isNullOrEmpty())
assert(!res.err.isNullOrEmpty())
assertFalse(res.success)
assertTrue(res.out.isNullOrEmpty())
assertFalse(res.err.isNullOrEmpty())
}
}

View file

@ -3,6 +3,7 @@ package org.domaindrivenarchitecture.provs.framework.ubuntu.keys
import org.domaindrivenarchitecture.provs.framework.core.Secret
import org.domaindrivenarchitecture.provs.test.defaultTestContainer
import org.domaindrivenarchitecture.provs.test.tags.NonCi
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
internal class ProvisionKeysTest {
@ -20,7 +21,7 @@ internal class ProvisionKeysTest {
)
// then
assert(res.success)
assertTrue(res.success)
}
}

View file

@ -36,7 +36,7 @@ internal class ProvisionUserKtTest {
)
// then
assert(res.success)
assertTrue(res.success)
}
@Test

View file

@ -126,9 +126,9 @@ internal class VerificationKtTest {
val res3 = testLocal().verifySocketSpec(SocketSpec("sshd", 22, running = false), out).success
// then
assert(res.success)
assert(!res2)
assert(!res3)
assertTrue(res.success)
assertFalse(res2)
assertFalse(res3)
}
}