Skip to content

Commit

Permalink
fix: lookup the provider tag from system properties for JUnit based t…
Browse files Browse the repository at this point in the history
…ests #823 #960
  • Loading branch information
Ronald Holshausen committed Oct 27, 2019
1 parent d8fdaa1 commit 343bd92
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object DefaultTestResultAccumulator : TestResultAccumulator, KLogging() {
} else {
verificationReporter.reportResults(pact, interactionResults.values.fold(TestResult.Ok) {
acc: TestResult, result -> acc.merge(result)
}, lookupProviderVersion())
}, lookupProviderVersion(), null, lookupProviderTag())
}
testResults.remove(pactHash)
} else {
Expand All @@ -81,6 +81,8 @@ object DefaultTestResultAccumulator : TestResultAccumulator, KLogging() {
}
}

private fun lookupProviderTag(): String? = System.getProperty("pact.provider.tag")

fun allInteractionsVerified(pact: Pact<out Interaction>, results: MutableMap<Int, TestResult>): Boolean {
logger.debug { "Number of interactions #${pact.interactions.size} and results: ${results.values}" }
return pact.interactions.all { results.containsKey(calculateInteractionHash(it)) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,28 @@ class TestResultAccumulatorSpec extends Specification {
testResultAccumulator.verificationReporter = reporter
}

@RestoreSystemProperties
def 'updateTestResult - include the provider tag'() {
given:
def pact = new RequestResponsePact(new Provider('provider'), new Consumer('consumer'),
[interaction1])
testResultAccumulator.testResults.clear()
def reporter = testResultAccumulator.verificationReporter
testResultAccumulator.verificationReporter = Mock(VerificationReporter) {
publishingResultsDisabled() >> false
}
System.setProperty('pact.provider.tag', 'updateTestResultTag')

when:
testResultAccumulator.updateTestResult(pact, interaction1, TestResult.Ok.INSTANCE)

then:
1 * testResultAccumulator.verificationReporter.reportResults(_, TestResult.Ok.INSTANCE, _, _,
'updateTestResultTag')
testResultAccumulator.testResults.isEmpty()

cleanup:
testResultAccumulator.verificationReporter = reporter
}

}

0 comments on commit 343bd92

Please sign in to comment.