Skip to content

Instantly share code, notes, and snippets.

View rafaelaazevedo's full-sized avatar

Rafaela Azevedo rafaelaazevedo

View GitHub Profile
const { Verifier } = require("@pact-foundation/pact")
const chai = require("chai")
const chaiAsPromised = require("chai-as-promised")
chai.use(chaiAsPromised)
const { server, importData, animalRepository } = require("../provider.js")
const path = require("path")
server.listen(8081, () => {
importData()
console.log("Animal Profile Service listening on http://localhost:8081")
const credentials = { username: "test", password: "123"}
willRespondWith: {
status: 200,
body: Matchers.somethingLike(name: "Mary", age: 20)
}
query: {
name: 'Mary Jame',
age: '8',
children: ['Betty', 'Sue']
}
body: {
name: "Mary",
age: Matchers.like(73)
}
body: {
name: "Mary",
dateOfBirthday: Matchers.term(
generate: "02/11/2013",
matcher:/\d{2}\/\d{2}\/\d{4}/)
}
describe('Pact Verification', () => {
if('should validate the contract', () =>
let opts = {
customProviderHeaders: ["Authorization: Bearer tu834r93h8rygr38y4r"]
};
return provider.verify(opts)
})
})
$ pact-broker can-i-deploy --pacticipant Cat --version 21 --pacticipant Dog --version 32
// Bad practice
const EXPECTED_BODY = {
name: fake.name,
surname: fake.surname,
createdDate: Date.now(),
country: fake.country()
}
// Good practice
const EXPECTED_BODY = {
@rafaelaazevedo
rafaelaazevedo / docker-clean.sh
Last active August 23, 2023 13:51
Clean all docker images/containers/volumes script
#!/bin/bash
# Kill all running containers.
docker kill $(docker ps -q)
# Delete all stopped containers.
printf "\n>>> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q)
# Delete all untagged images.