replace assert in tests with junit assertTrue
This commit is contained in:
parent
22018a141f
commit
ef56118ccb
8 changed files with 45 additions and 47 deletions
|
@ -5,7 +5,7 @@
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
<option name="MAIN_CLASS_NAME" value="" />
|
||||||
<option name="METHOD_NAME" value="" />
|
<option name="METHOD_NAME" value="" />
|
||||||
<option name="TEST_OBJECT" value="tags" />
|
<option name="TEST_OBJECT" value="tags" />
|
||||||
<option name="VM_PARAMETERS" value="-DexcludeTags="containertest"" />
|
<option name="VM_PARAMETERS" />
|
||||||
<tag value="!containertest" />
|
<tag value="!containertest" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Make" enabled="true" />
|
<option name="Make" enabled="true" />
|
||||||
|
|
|
@ -15,11 +15,11 @@ import java.io.PrintStream
|
||||||
|
|
||||||
internal class ProvTest {
|
internal class ProvTest {
|
||||||
|
|
||||||
private fun Prov.task_returningFalse() = task {
|
private fun Prov.task_returningFalse() = taskWithResult {
|
||||||
ProvResult(false)
|
ProvResult(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Prov.task_returningTrue() = task {
|
private fun Prov.task_returningTrue() = taskWithResult {
|
||||||
ProvResult(true)
|
ProvResult(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ internal class ProvTest {
|
||||||
val res = Prov.newInstance(name = "testing").cmd("echo --testing--").success
|
val res = Prov.newInstance(name = "testing").cmd("echo --testing--").success
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res)
|
assertTrue(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -49,7 +49,7 @@ internal class ProvTest {
|
||||||
val res = Prov.newInstance(name = "testing").sh(script).success
|
val res = Prov.newInstance(name = "testing").sh(script).success
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res)
|
assertTrue(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -70,7 +70,7 @@ internal class ProvTest {
|
||||||
val res = Prov.newInstance(name = "provs_test").sh(script, "/root", true).success
|
val res = Prov.newInstance(name = "provs_test").sh(script, "/root", true).success
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res)
|
assertTrue(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -86,7 +86,7 @@ internal class ProvTest {
|
||||||
val res = testLocal().tst_task().success
|
val res = testLocal().tst_task().success
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res)
|
assertTrue(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -101,7 +101,7 @@ internal class ProvTest {
|
||||||
val res = testLocal().tst_task().success
|
val res = testLocal().tst_task().success
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res)
|
assertTrue(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -116,7 +116,7 @@ internal class ProvTest {
|
||||||
val res = testLocal().tst_task().success
|
val res = testLocal().tst_task().success
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(!res)
|
assertFalse(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -131,7 +131,7 @@ internal class ProvTest {
|
||||||
val res = testLocal().tst_task_all_true_mode_ALL().success
|
val res = testLocal().tst_task_all_true_mode_ALL().success
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res)
|
assertTrue(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
// given
|
// given
|
||||||
|
@ -147,7 +147,7 @@ internal class ProvTest {
|
||||||
val res = testLocal().tst_task_one_false_mode_ALL().success
|
val res = testLocal().tst_task_one_false_mode_ALL().success
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(!res)
|
assertFalse(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
// given
|
// given
|
||||||
|
@ -169,7 +169,7 @@ internal class ProvTest {
|
||||||
val res = testLocal().tst_task_one_false_mode_ALL_nested().success
|
val res = testLocal().tst_task_one_false_mode_ALL_nested().success
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(!res)
|
assertFalse(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -189,7 +189,7 @@ internal class ProvTest {
|
||||||
val res = testLocal().tst_task_one_false_mode_ALL().success
|
val res = testLocal().tst_task_one_false_mode_ALL().success
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(!res)
|
assertFalse(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -209,7 +209,7 @@ internal class ProvTest {
|
||||||
val res = testLocal().tst_task_failexit_outer().success
|
val res = testLocal().tst_task_failexit_outer().success
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(!res)
|
assertFalse(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -229,7 +229,7 @@ internal class ProvTest {
|
||||||
val res = testLocal().tst_task_failexit_outer().success
|
val res = testLocal().tst_task_failexit_outer().success
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res)
|
assertTrue(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -254,7 +254,7 @@ internal class ProvTest {
|
||||||
val res = testLocal().tst_nested().success
|
val res = testLocal().tst_nested().success
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(!res)
|
assertFalse(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,7 @@ import org.domaindrivenarchitecture.provs.test.tags.ContainerTest
|
||||||
import org.domaindrivenarchitecture.provs.test.tags.NonCi
|
import org.domaindrivenarchitecture.provs.test.tags.NonCi
|
||||||
import org.domaindrivenarchitecture.provs.test.testDockerWithSudo
|
import org.domaindrivenarchitecture.provs.test.testDockerWithSudo
|
||||||
import org.domaindrivenarchitecture.provs.test.testLocal
|
import org.domaindrivenarchitecture.provs.test.testLocal
|
||||||
import org.junit.jupiter.api.Assertions.assertEquals
|
import org.junit.jupiter.api.Assertions.*
|
||||||
import org.junit.jupiter.api.Assertions.assertFalse
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
internal class UbuntuProvTest {
|
internal class UbuntuProvTest {
|
||||||
|
@ -28,9 +27,9 @@ internal class UbuntuProvTest {
|
||||||
val res2 = a.cmd("echo abc", dir)
|
val res2 = a.cmd("echo abc", dir)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res1.success)
|
assertTrue(res1.success)
|
||||||
assert(res2.success)
|
assertTrue(res2.success)
|
||||||
assert(res2.out?.trim() == "abc")
|
assertTrue(res2.out?.trim() == "abc")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -43,8 +42,8 @@ internal class UbuntuProvTest {
|
||||||
val res1 = a.cmd("echo abc", "/root", sudo = true)
|
val res1 = a.cmd("echo abc", "/root", sudo = true)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res1.success)
|
assertTrue(res1.success)
|
||||||
assert(res1.out?.trim() == "abc")
|
assertTrue(res1.out?.trim() == "abc")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -58,9 +57,9 @@ internal class UbuntuProvTest {
|
||||||
val res2 = a.cmd("echo abc", dir)
|
val res2 = a.cmd("echo abc", dir)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res1.success)
|
assertTrue(res1.success)
|
||||||
assert(res2.success)
|
assertTrue(res2.success)
|
||||||
assert(res2.out?.trim() == "abc")
|
assertTrue(res2.out?.trim() == "abc")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -73,10 +72,10 @@ internal class UbuntuProvTest {
|
||||||
val res2 = a.exec("/bin/bash", "-c", "echo echoed")
|
val res2 = a.exec("/bin/bash", "-c", "echo echoed")
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res1.success)
|
assertTrue(res1.success)
|
||||||
assert(res1.out?.trim() == "hi")
|
assertTrue(res1.out?.trim() == "hi")
|
||||||
assert(res2.success)
|
assertTrue(res2.success)
|
||||||
assert(res2.out?.trim() == "echoed")
|
assertTrue(res2.out?.trim() == "echoed")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -4,9 +4,8 @@ import org.domaindrivenarchitecture.provs.framework.core.newline
|
||||||
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.ContainerTest
|
||||||
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.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.condition.EnabledOnOs
|
|
||||||
import org.junit.jupiter.api.condition.OS
|
|
||||||
|
|
||||||
internal class ContainerProcessorTest {
|
internal class ContainerProcessorTest {
|
||||||
|
|
||||||
|
@ -22,7 +21,7 @@ internal class ContainerProcessorTest {
|
||||||
val res = prov.cmd("echo '${text}'")
|
val res = prov.cmd("echo '${text}'")
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res.success)
|
assertTrue(res.success)
|
||||||
assertEquals(text + newline(), res.out)
|
assertEquals(text + newline(), res.out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +37,7 @@ internal class ContainerProcessorTest {
|
||||||
val res = prov.cmdNoLog("echo '${text}'")
|
val res = prov.cmdNoLog("echo '${text}'")
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res.success)
|
assertTrue(res.success)
|
||||||
assertEquals(text + newline(), res.out)
|
assertEquals(text + newline(), res.out)
|
||||||
|
|
||||||
// todo add check that cmd was not logged
|
// todo add check that cmd was not logged
|
||||||
|
|
|
@ -4,8 +4,7 @@ import org.domaindrivenarchitecture.provs.framework.core.Prov
|
||||||
import org.domaindrivenarchitecture.provs.framework.core.escapeAndEncloseByDoubleQuoteForShell
|
import org.domaindrivenarchitecture.provs.framework.core.escapeAndEncloseByDoubleQuoteForShell
|
||||||
import org.domaindrivenarchitecture.provs.framework.core.escapeProcentForPrintf
|
import org.domaindrivenarchitecture.provs.framework.core.escapeProcentForPrintf
|
||||||
import org.domaindrivenarchitecture.provs.framework.core.escapeSingleQuoteForShell
|
import org.domaindrivenarchitecture.provs.framework.core.escapeSingleQuoteForShell
|
||||||
import org.junit.jupiter.api.Assertions.assertEquals
|
import org.junit.jupiter.api.Assertions.*
|
||||||
import org.junit.jupiter.api.Assertions.assertTrue
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,8 +20,8 @@ internal class LocalProcessorTest {
|
||||||
val res = prov.cmd("printf '${text.replace("%", "%%").escapeSingleQuoteForShell()}'")
|
val res = prov.cmd("printf '${text.replace("%", "%%").escapeSingleQuoteForShell()}'")
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res.success)
|
assertTrue(res.success)
|
||||||
assert(res.out == text)
|
assertTrue(res.out == text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ internal class LocalProcessorTest {
|
||||||
val res = prov.cmdNoLog("echo $osSpecificText")
|
val res = prov.cmdNoLog("echo $osSpecificText")
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res.success)
|
assertTrue(res.success)
|
||||||
assertEquals( text + System.lineSeparator(), res.out)
|
assertEquals( text + System.lineSeparator(), res.out)
|
||||||
|
|
||||||
// todo add check that cmd was not logged
|
// todo add check that cmd was not logged
|
||||||
|
@ -68,8 +67,8 @@ internal class LocalProcessorTest {
|
||||||
val res = prov.cmd("iamanunknowncmd")
|
val res = prov.cmd("iamanunknowncmd")
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(!res.success)
|
assertFalse(res.success)
|
||||||
assert(res.out.isNullOrEmpty())
|
assertTrue(res.out.isNullOrEmpty())
|
||||||
assert(!res.err.isNullOrEmpty())
|
assertFalse(res.err.isNullOrEmpty())
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,6 +3,7 @@ package org.domaindrivenarchitecture.provs.framework.ubuntu.keys
|
||||||
import org.domaindrivenarchitecture.provs.framework.core.Secret
|
import org.domaindrivenarchitecture.provs.framework.core.Secret
|
||||||
import org.domaindrivenarchitecture.provs.test.defaultTestContainer
|
import org.domaindrivenarchitecture.provs.test.defaultTestContainer
|
||||||
import org.domaindrivenarchitecture.provs.test.tags.NonCi
|
import org.domaindrivenarchitecture.provs.test.tags.NonCi
|
||||||
|
import org.junit.jupiter.api.Assertions.assertTrue
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
internal class ProvisionKeysTest {
|
internal class ProvisionKeysTest {
|
||||||
|
@ -20,7 +21,7 @@ internal class ProvisionKeysTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res.success)
|
assertTrue(res.success)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ internal class ProvisionUserKtTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res.success)
|
assertTrue(res.success)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -126,9 +126,9 @@ internal class VerificationKtTest {
|
||||||
val res3 = testLocal().verifySocketSpec(SocketSpec("sshd", 22, running = false), out).success
|
val res3 = testLocal().verifySocketSpec(SocketSpec("sshd", 22, running = false), out).success
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert(res.success)
|
assertTrue(res.success)
|
||||||
assert(!res2)
|
assertFalse(res2)
|
||||||
assert(!res3)
|
assertFalse(res3)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue