Skip to content

Instantly share code, notes, and snippets.

Avatar

Erich Douglass erd

View GitHub Profile
@erd
erd / post-actions.sh
Last active Oct 31, 2018
Contract Testing with Pact #16
View post-actions.sh
# PATH_TO_JSON: this will be something like ~/workspace/project/tmp/pacts/pact.json
# PACT_USERNAME: your Pact broker username
# PACT_PASSWORD: your Pact broker password
# PACT_BROKER_URL: this is the url to your pact broker, anteceded by the version and version number.
# For example: https://company.pact.dius.com.au/pacts/provider/company-bff/company/company-ios-app/version/1.0.1
curl -v -X PUT -H "Content-Type: application/json" -T <PATH_TO_JSON> -u <PACT_USERNAME>:<PACT_PASSWORD> <PACT_BROKER_URL>
@erd
erd / BootstrapApiTest.swift
Last active Oct 31, 2018
Contract Testing with Pact #15
View BootstrapApiTest.swift
var provider: MockService!
var client: BootstrapClient!
beforeEach {
provider = MockService(provider: "consumer-mobile-bff", consumer: "consumer-ios")
client = BootstrapClient(baseUrl: provider!.baseUrl)
}
it("should fetch bootstrap information from provider") {
provider!.given("default")
@erd
erd / post-actions.sh
Created Oct 31, 2018
Contract Testing with Pact #14
View post-actions.sh
pact-mock-service stop
@erd
erd / pre-actions.sh
Created Oct 31, 2018
Contract Testing with Pact #13
View pre-actions.sh
pact-mock-service start --pact-specification-version 2.0.0 --log "${SRCROOT}/tmp/pact.log" --pact-dir "${SRCROOT}/tmp/pacts" -p 1234
@erd
erd / Podfile
Created Oct 31, 2018
Contract Testing with Pact #12
View Podfile
pod 'PactConsumerSwift'
@erd
erd / Gemfile
Created Oct 31, 2018
Contract Testing with Pact #11
View Gemfile
sudo gem install pact-mock-service
@erd
erd / BootstrapApiTest.kt
Created Oct 31, 2018
Contract Testing with Pact #11
View BootstrapApiTest.kt
@Test
@PactVerification
fun `should fetch bootstrap information from provider`() {
val client = buildRetrofitClient(provider.url)
val response = client.bootstrap().blockingGet()
val version = response.version
assertThat(version.currentVersion).isNotBlank()
assertThat(version.minimumVersion).isNotBlank()
}
@erd
erd / BootstrapApiTest.kt
Created Oct 31, 2018
Contract Testing with Pact #10
View BootstrapApiTest.kt
@Pact(consumer = "consumer-android")
fun createPact(builder: PactDslWithProvider): RequestResponsePact {
return builder
.given("default")
.uponReceiving("Fetching application bootstrap information")
.path("/v1/bootstrap")
.method("GET") .headers(mapOf(
"User-Agent" to "DoorDashConsumer/Android"
))
.willRespondWith()
@erd
erd / BootstrapApiTest.kt
Created Oct 31, 2018
Contract Testing with Pact #9
View BootstrapApiTest.kt
@Rule @JvmField
val provider = PactProviderRuleMk2("consumer-mobile-bff", this)
@erd
erd / build.gradle
Created Oct 31, 2018
Contract Testing with Pact #8
View build.gradle
testImplementation 'au.com.dius:pact-jvm-consumer-junit_2.12:3.5.12'
testImplementation 'au.com.dius:pact-jvm-consumer-java8_2.12:3.5.12'