Skip to content

Commit

Permalink
fix: merge in results so we don't lose results with multiple interact…
Browse files Browse the repository at this point in the history
…ions #1128
  • Loading branch information
Ronald Holshausen committed Oct 17, 2020
1 parent 7a77597 commit 7f34c22
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import au.com.dius.pact.provider.junitsupport.Provider;
import au.com.dius.pact.provider.junitsupport.State;
import au.com.dius.pact.provider.junitsupport.StateChangeAction;
import au.com.dius.pact.provider.junitsupport.VerificationReports;
import au.com.dius.pact.provider.junitsupport.loader.PactFolder;
import au.com.dius.pact.provider.junitsupport.target.Target;
import au.com.dius.pact.provider.junitsupport.target.TestTarget;
Expand All @@ -26,6 +27,7 @@
@RunWith(PactRunner.class)
@Provider("ArticlesProvider")
@PactFolder("src/test/resources/wildcards")
@VerificationReports({"console", "markdown"})
public class ArticlesContractTest {

private static final Logger LOGGER = LoggerFactory.getLogger(ArticlesContractTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class MarkdownReporter(
this.provider = provider
reportDir!!.mkdirs()
reportFile = File(reportDir, provider.name + ext)
events.clear()
}

override fun finaliseReport() {
Expand Down Expand Up @@ -138,15 +139,15 @@ class MarkdownReporter(
val document = parser.parseReader(BufferedReader(FileReader(reportFile)))

val (consumer: IConsumerInfo?, state) = consumerAndStatus(document)

val header = events.find { it.type == "reportVerificationForConsumer" }?.contents?.substring(2)?.trim()
if (consumer != null) {
var consumerSection: Node? = null
for (child in document.children) {
if (child is Heading && child.text.unescape() == "Summary") {
updateSummary(child.next, consumer, state)
}

if (child is Heading && child.text.startsWith("Verifying a pact between _" + consumer.name)) {
if (child is Heading && child.text.contains(header.toString())) {
consumerSection = child
}
}
Expand All @@ -157,20 +158,25 @@ class MarkdownReporter(
document.appendChild(section)
}
} else {
val prevChild = consumerSection.previous
var child = consumerSection.next
consumerSection.unlink()
while (child != null && child !is Heading) {
val currentChild = child
child = child.next
currentChild.unlink()
}

child = prevChild
for (event in events) {
val section = parser.parseReader(StringReader(event.contents))
child!!.insertAfter(section)
child = section
if (child == null) {
for (event in events) {
if (event.type != "reportVerificationForConsumer") {
val section = parser.parseReader(StringReader(event.contents))
document.appendChild(section)
}
}
} else {
for (event in events) {
if (event.type != "reportVerificationForConsumer") {
val section = parser.parseReader(StringReader(event.contents))
child.insertBefore(section)
}
}
}
}
}
Expand Down

0 comments on commit 7f34c22

Please sign in to comment.