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

Consumer versions selectors v2 #258

Merged
merged 2 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ lazy val shared =
.settings(
name := "pact4s-core",
libraryDependencies ++= Dependencies.shared,
scalacOptions ++= {
if (scalaVersion.value.startsWith("3")) Seq("-Wconf:cat=deprecation:i") else Nil
}
scalacOptions += "-Wconf:cat=deprecation:i"
)

lazy val circe =
Expand Down Expand Up @@ -150,6 +148,7 @@ addCommandAlias(
"scalafmtCheck",
"headerCheck",
"+compile:doc",
"+test:compile",
"deletePactFiles",
"project munit",
"+test",
Expand All @@ -160,7 +159,8 @@ addCommandAlias(
"project circe",
"+test",
"project playJson",
"+test"
"+test",
"project /"
)
.mkString(";", ";", "")
)
Expand All @@ -173,6 +173,7 @@ addCommandAlias(
"scalafmtCheck",
"headerCheck",
"compile:doc",
"test:compile",
"deletePactFiles",
"project munit",
"test",
Expand All @@ -183,7 +184,8 @@ addCommandAlias(
"project circe",
"test",
"project playJson",
"test"
"test",
"project /"
)
.mkString(";", ";", "")
)
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PactForgerSuite extends RequestResponsePactForger {
.method("GET")
.willRespondWith()
.status(204)
.`given`("bob exists")
.`given`("bob exists", Map("foo" -> "bar"))
.uponReceiving("a request to find a friend")
.path("/anyone-there")
.method("GET")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import cats.effect.IO
import munit.CatsEffectSuite
import pact4s.MockProviderServer
import pact4s.munit.PactVerifier
import pact4s.provider.{Branch, ConsumerVersionSelector, ProviderInfoBuilder, PublishVerificationResults}
import pact4s.provider.{Branch, ConsumerVersionSelectors, ProviderInfoBuilder}

class PactVerifierBrokerFeatureBranchSuite extends CatsEffectSuite with PactVerifier {
val mock = new MockProviderServer(49164, hasFeatureX = true)

override val provider: ProviderInfoBuilder =
mock.brokerProviderInfo("Pact4sProvider", consumerVersionSelector = ConsumerVersionSelector().withBranch("feat/x"))
mock.brokerProviderInfo("Pact4sProvider", consumerVersionSelector = ConsumerVersionSelectors.branch("feat/x"))

override val munitFixtures: Seq[Fixture[_]] = Seq(
ResourceSuiteLocalFixture(
Expand All @@ -22,11 +22,8 @@ class PactVerifierBrokerFeatureBranchSuite extends CatsEffectSuite with PactVeri
test("Verify pacts for provider `Pact4sProvider` with a feature branch, munit") {
IO(
verifyPacts(
publishVerificationResults = Some(
PublishVerificationResults(
providerVersion = "SNAPSHOT",
providerBranch = Branch("feat/x")
)
Some(
Branch("feat/x")
)
)
) *> mock.featureXState.tryGet.assertEquals(Some(true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import cats.effect.IO
import munit.CatsEffectSuite
import pact4s.MockProviderServer
import pact4s.munit.PactVerifier
import pact4s.provider.{Branch, ConsumerVersionSelector, ProviderInfoBuilder, PublishVerificationResults}
import pact4s.provider.{Branch, ConsumerVersionSelectors, ProviderInfoBuilder}

class PactVerifierBrokerMatchingBranchSuite extends CatsEffectSuite with PactVerifier {
val mock = new MockProviderServer(49264, hasFeatureX = true)

override val provider: ProviderInfoBuilder =
mock.brokerProviderInfo(
"Pact4sProvider",
consumerVersionSelector = ConsumerVersionSelector().withMatchingBranch
consumerVersionSelector = ConsumerVersionSelectors.matchingBranch
)

override val munitFixtures: Seq[Fixture[_]] = Seq(
Expand All @@ -25,11 +25,8 @@ class PactVerifierBrokerMatchingBranchSuite extends CatsEffectSuite with PactVer
test("Verify pacts for provider `Pact4sProvider` with a feature branch and matching branch selector, munit") {
IO(
verifyPacts(
publishVerificationResults = Some(
PublishVerificationResults(
providerVersion = "SNAPSHOT",
providerBranch = Branch("feat/x")
)
Some(
Branch("feat/x")
)
)
) *> mock.featureXState.tryGet.assertEquals(Some(true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import cats.effect.IO
import munit.CatsEffectSuite
import pact4s.MockProviderServer
import pact4s.munit.PactVerifier
import pact4s.provider.{Branch, ConsumerVersionSelector, ProviderInfoBuilder, PublishVerificationResults}
import pact4s.provider.{Branch, ConsumerVersionSelectors, ProviderInfoBuilder}

class PactVerifierBrokerSuite extends CatsEffectSuite with PactVerifier {
val mock = new MockProviderServer(49154)

override val provider: ProviderInfoBuilder =
mock.brokerProviderInfo("Pact4sProvider", consumerVersionSelector = ConsumerVersionSelector().withMainBranch)
mock.brokerProviderInfo("Pact4sProvider", consumerVersionSelector = ConsumerVersionSelectors.mainBranch)

override val munitFixtures: Seq[Fixture[_]] = Seq(
ResourceSuiteLocalFixture(
Expand All @@ -22,11 +22,8 @@ class PactVerifierBrokerSuite extends CatsEffectSuite with PactVerifier {
test("Verify pacts for provider `Pact4sProvider`, munit") {
IO(
verifyPacts(
publishVerificationResults = Some(
PublishVerificationResults(
providerVersion = "SNAPSHOT",
providerBranch = Branch.MAIN
)
Some(
Branch.MAIN
)
)
) *> mock.featureXState.tryGet.assertEquals(None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class PactForgerSuite extends AnyFlatSpec with Matchers with RequestResponsePact
.method("GET")
.willRespondWith()
.status(204)
.`given`("bob exists")
.`given`("bob exists", Map("foo" -> "bar"))
.uponReceiving("a request to find a friend")
.path("/anyone-there")
.method("GET")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.scalatest.BeforeAndAfterAll
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import pact4s.MockProviderServer
import pact4s.provider.{Branch, ConsumerVersionSelector, ProviderInfoBuilder, PublishVerificationResults}
import pact4s.provider.{Branch, ConsumerVersionSelectors, ProviderInfoBuilder}
import pact4s.scalatest.PactVerifier

import scala.concurrent.duration._
Expand All @@ -15,7 +15,7 @@ class PactVerifierBrokerFeatureBranchSuite extends AnyFlatSpec with PactVerifier
val mock = new MockProviderServer(49200, hasFeatureX = true)

override val provider: ProviderInfoBuilder =
mock.brokerProviderInfo("Pact4sProvider", consumerVersionSelector = ConsumerVersionSelector().withBranch("feat/x"))
mock.brokerProviderInfo("Pact4sProvider", consumerVersionSelector = ConsumerVersionSelectors.branch("feat/x"))

var cleanUp: IO[Unit] = IO.unit

Expand All @@ -29,12 +29,7 @@ class PactVerifierBrokerFeatureBranchSuite extends AnyFlatSpec with PactVerifier

it should "Verify pacts for provider `Pact4sProvider` with a feature branch, scalatest" in {
verifyPacts(
publishVerificationResults = Some(
PublishVerificationResults(
providerVersion = "SNAPSHOT",
providerBranch = Branch("feat/x")
)
)
Some(Branch("feat/x"))
)
mock.featureXState.get.unsafeRunTimed(10.seconds) shouldBe Some(true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.scalatest.BeforeAndAfterAll
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import pact4s.MockProviderServer
import pact4s.provider.{Branch, ConsumerVersionSelector, ProviderInfoBuilder, PublishVerificationResults}
import pact4s.provider.{Branch, ConsumerVersionSelectors, ProviderInfoBuilder}
import pact4s.scalatest.PactVerifier

import scala.concurrent.duration._
Expand All @@ -17,7 +17,7 @@ class PactVerifierBrokerMatchingBranchSuite extends AnyFlatSpec with PactVerifie
override val provider: ProviderInfoBuilder =
mock.brokerProviderInfo(
"Pact4sProvider",
consumerVersionSelector = ConsumerVersionSelector().withMatchingBranch
consumerVersionSelector = ConsumerVersionSelectors.matchingBranch
)

var cleanUp: IO[Unit] = IO.unit
Expand All @@ -32,12 +32,7 @@ class PactVerifierBrokerMatchingBranchSuite extends AnyFlatSpec with PactVerifie

it should "Verify pacts for provider `Pact4sProvider` with a feature branch and matching branch selector, scalatest" in {
verifyPacts(
publishVerificationResults = Some(
PublishVerificationResults(
providerVersion = "SNAPSHOT",
providerBranch = Branch("feat/x")
)
)
Some(Branch("feat/x"))
)
mock.featureXState.get.unsafeRunTimed(10.seconds) shouldBe Some(true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import org.scalatest.BeforeAndAfterAll
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import pact4s.MockProviderServer
import pact4s.provider.{Branch, ConsumerVersionSelector, ProviderInfoBuilder, PublishVerificationResults}
import pact4s.provider.{Branch, ConsumerVersionSelectors, ProviderInfoBuilder}
import pact4s.scalatest.PactVerifier

class PactVerifierBrokerSuite extends AnyFlatSpec with PactVerifier with BeforeAndAfterAll with Matchers {
val mock = new MockProviderServer(49158)

override val provider: ProviderInfoBuilder =
mock.brokerProviderInfo("Pact4sProvider", consumerVersionSelector = ConsumerVersionSelector().withMainBranch)
mock.brokerProviderInfo("Pact4sProvider", consumerVersionSelector = ConsumerVersionSelectors.mainBranch)

var cleanUp: IO[Unit] = IO.unit

Expand All @@ -27,12 +27,7 @@ class PactVerifierBrokerSuite extends AnyFlatSpec with PactVerifier with BeforeA

it should "Verify pacts for provider `Pact4sProvider`, scalatest" in {
verifyPacts(
publishVerificationResults = Some(
PublishVerificationResults(
providerVersion = "SNAPSHOT",
providerBranch = Branch.MAIN
)
)
Some(Branch.MAIN)
)
mock.featureXState.tryGet.unsafeRunSync() shouldBe None
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/Pact4sConsumer-Pact4sProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
],
"metadata": {
"pact-jvm": {
"version": "4.3.7"
"version": "4.3.14"
},
"pactSpecification": {
"version": "3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion scripts/Pact4sMessageConsumer-Pact4sMessageProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
],
"metadata": {
"pact-jvm": {
"version": "4.3.7"
"version": "4.3.14"
},
"pactSpecification": {
"version": "3.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
],
"metadata": {
"pact-jvm": {
"version": "4.3.5"
"version": "4.3.14"
},
"pactSpecification": {
"version": "3.0.0"
Expand Down
6 changes: 4 additions & 2 deletions scripts/publish_pacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ docker run --rm \
publish \
${SCRIPT_DIR} \
--consumer-app-version fake-git-sha-for-demo-$(date +%s) \
--branch main
--branch main \
--tag pact4s-test

docker run --rm \
-w "${SCRIPT_DIR}/feature" \
Expand All @@ -28,4 +29,5 @@ docker run --rm \
publish \
"${SCRIPT_DIR}/feature" \
--consumer-app-version fake-git-sha-for-demo-$(date +%s) \
--branch feat/x
--branch feat/x \
--tag pact4s-test
Loading