You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
876 B
Kotlin
37 lines
876 B
Kotlin
package org.domaindrivenarchitecture.provs.framework.core
|
|
|
|
import org.domaindrivenarchitecture.provs.test.testLocal
|
|
import org.junit.jupiter.api.Assertions.*
|
|
import org.junit.jupiter.api.Test
|
|
|
|
internal class TaskFunctionsKtTest {
|
|
|
|
var count = 1
|
|
fun Prov.altenateSuccessAndFailure() = task {
|
|
if (count == 0) {
|
|
count = 1
|
|
ProvResult(true, out = "0")
|
|
} else {
|
|
count--
|
|
ProvResult(false, err = "1")
|
|
}
|
|
}
|
|
|
|
fun Prov.repeating() = requireLast {
|
|
val res = repeatTaskUntilSuccess(4, 1) {
|
|
altenateSuccessAndFailure()
|
|
}
|
|
|
|
if (res.success && ("0" == res.out?.trim())) {
|
|
ProvResult(true)
|
|
} else {
|
|
ProvResult(false)
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
fun repeat_and_requireLast() {
|
|
assertTrue(testLocal().repeating().success)
|
|
}
|
|
} |