-
-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add retry when there are unknown results for canIDeploy #1241
- Loading branch information
Ronald Holshausen
committed
Nov 14, 2020
1 parent
6720091
commit 8ec6d2a
Showing
24 changed files
with
344 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
core/pactbroker/src/test/kotlin/au/com/dius/pact/core/pactbroker/PactBrokerClientTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package au.com.dius.pact.core.pactbroker | ||
|
||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.hamcrest.Matchers.equalTo | ||
import org.junit.jupiter.api.Test | ||
|
||
class PactBrokerClientTest { | ||
@Test | ||
fun retryWithWhenCountIsZeroRunsOnce() { | ||
var counter = 0 | ||
val result = PactBrokerClient.retryWith("Test", 0, 0, { false }) { | ||
counter += 1 | ||
counter | ||
} | ||
assertThat(result, equalTo(1)) | ||
} | ||
|
||
@Test | ||
fun retryWithWhenCountIsOneRunsOnce() { | ||
var counter = 0 | ||
val result = PactBrokerClient.retryWith("Test", 1, 0, { false }) { | ||
counter += 1 | ||
counter | ||
} | ||
assertThat(result, equalTo(1)) | ||
} | ||
|
||
@Test | ||
fun retryWithWhenCountIsGreaterThanOneButPredicateIsFalseRunsOnce() { | ||
var counter = 0 | ||
val result = PactBrokerClient.retryWith("Test", 10, 0, { false }) { | ||
counter += 1 | ||
counter | ||
} | ||
assertThat(result, equalTo(1)) | ||
} | ||
|
||
@Test | ||
fun retryWithWhenCountIsGreaterThanOneAndPredicateIsTrueRunsTheNumberOfTimeByTheCount() { | ||
var counter = 0 | ||
val result = PactBrokerClient.retryWith("Test", 10, 0, { true }) { | ||
counter += 1 | ||
counter | ||
} | ||
assertThat(result, equalTo(10)) | ||
} | ||
|
||
@Test | ||
fun retryWithWhenCountIsGreaterThanOneRunsUntilThePredicateIsFalse() { | ||
var counter = 0 | ||
val result = PactBrokerClient.retryWith("Test", 10, 0, { v -> v < 5 }) { | ||
counter += 1 | ||
counter | ||
} | ||
assertThat(result, equalTo(5)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 16 additions & 9 deletions
25
provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/Broker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
package au.com.dius.pact.provider.gradle | ||
|
||
import groovy.transform.ToString | ||
|
||
/** | ||
* Config for pact broker | ||
*/ | ||
@ToString | ||
class Broker { | ||
String pactBrokerUrl | ||
String pactBrokerToken | ||
String pactBrokerUsername | ||
String pactBrokerPassword | ||
String pactBrokerAuthenticationScheme | ||
data class Broker( | ||
var pactBrokerUrl: String? = null, | ||
var pactBrokerToken: String? = null, | ||
var pactBrokerUsername: String? = null, | ||
var pactBrokerPassword: String? = null, | ||
var pactBrokerAuthenticationScheme: String? = null, | ||
var retryCountWhileUnknown: Int? = null, | ||
var retryWhileUnknownInterval: Int? = null | ||
) { | ||
override fun toString(): String { | ||
val password = if (pactBrokerPassword != null) "".padEnd(pactBrokerPassword!!.length, '*') else null | ||
return "Broker(pactBrokerUrl=$pactBrokerUrl, pactBrokerToken=$pactBrokerToken, " + | ||
"pactBrokerUsername=$pactBrokerUsername, pactBrokerPassword=$password, " + | ||
"pactBrokerAuthenticationScheme=$pactBrokerAuthenticationScheme, " + | ||
"retryCountWhileUnknown=$retryCountWhileUnknown, retryWhileUnknownInterval=$retryWhileUnknownInterval)" | ||
} | ||
} |
Oops, something went wrong.