Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pact JUnit provider not publishing verification results if Pact URL is overridden #1049

Closed
arhohuttunen opened this issue Mar 16, 2020 · 1 comment

Comments

@arhohuttunen
Copy link
Contributor

arhohuttunen commented Mar 16, 2020

I added a workflow where a consumer triggers the verification on the provider side, and overrides the Pact URL with pact.filter.pacturl. The verification is being run correctly, but publishing the
results is being skipped.

Running the Gradle task with info level:

[Test worker] INFO  a.c.d.p.p.DefaultVerificationReporter.reportResults - Skipping publishing verification results for source UrlSource

I did some digging and found out this in DefaultVerificationReporter.kt:

  override fun reportResults(
    pact: Pact<out Interaction>,
    result: TestResult,
    version: String,
    client: PactBrokerClient?,
    tag: String?
  ) {
    when (val source = pact.source) {
      is BrokerUrlSource -> {
        val brokerClient = client ?: PactBrokerClient(source.pactBrokerUrl, source.options)
        publishResult(brokerClient, source, result, version, pact, tag)
      }
      else -> logger.info { "Skipping publishing verification results for source $source" }
    }
  }

So, if the type of the Pact source is not BrokerUrlSource, it skips the publishing of the results.

I think the culprit is most likely this piece of code in PactBrokerLoader.kt:

  override fun load(providerName: String): List<Pact<Interaction>> {
    val resolver = setupValueResolver()
    val pacts = when {
      overriddenPactUrl.isNotEmpty() -> {
        val pactBrokerClient = newPactBrokerClient(brokerUrl(resolver).build(), resolver)
        val pactSource = UrlSource<Interaction>(overriddenPactUrl!!)
  // ...

So, basically when we override the Pact URL, the Pact source here is created as an UrlSource which results into the verification results being skipped.

uglyog pushed a commit that referenced this issue Mar 21, 2020
fix: publish verification results when Pact URL is overridden #1049
@uglyog
Copy link
Member

uglyog commented Mar 22, 2020

4.0.8 released with this change

@anto-ac anto-ac closed this as completed Jun 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants