Skip to content

Commit

Permalink
fix: correct the pact source description when using the URL option #1449
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Holshausen committed Sep 28, 2021
1 parent 5706c60 commit bcc1d12
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package au.com.dius.pact.core.model

import au.com.dius.pact.core.pactbroker.PactBrokerResult
import au.com.dius.pact.core.support.isNotEmpty
import java.io.File
import java.util.function.Supplier

Expand Down Expand Up @@ -38,12 +39,13 @@ data class PactBrokerSource<I> @JvmOverloads constructor(
val url: String? = null
) : PactSource()
where I : Interaction {
override fun description() =
if (port == null) {
"Pact Broker $scheme://$host"
} else {
"Pact Broker $scheme://$host:$port"
override fun description(): String {
return when {
url.isNotEmpty() -> "Pact Broker $url"
port == null -> "Pact Broker $scheme://$host"
else -> "Pact Broker $scheme://$host:$port"
}
}
}

data class FileSource<I> @JvmOverloads constructor(val file: File, val pact: Pact<I>? = null) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ class PactBrokerSourceSpec extends Specification {
source.description() == description

where:
source | description
new PactBrokerSource('localhost', '80', 'http') | 'Pact Broker http://localhost:80'
new PactBrokerSource('www.example.com', '443', 'https') | 'Pact Broker https://www.example.com:443'
source | description
new PactBrokerSource('localhost', '80', 'http') | 'Pact Broker http://localhost:80'
new PactBrokerSource('www.example.com', '443', 'https') | 'Pact Broker https://www.example.com:443'
new PactBrokerSource(null, null, null, [:], 'https://www.example.com:443') | 'Pact Broker https://www.example.com:443'
}
}

0 comments on commit bcc1d12

Please sign in to comment.