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

Feat/message metadata #174

Merged
merged 7 commits into from
Jul 27, 2021
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
16 changes: 11 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
on: [push, pull_request]
name: Test

env:
PACT_BROKER_BASE_URL: https://testdemo.pactflow.io
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
REACT_APP_API_BASE_URL: http://localhost:8080
APP_SHA: ${{ github.sha }}
APP_BRANCH: ${{ github.ref }}
LD_LIBRARY_PATH: /tmp
PACT_GO_LIB_DOWNLOAD_PATH: /tmp
LOG_LEVEL: trace

jobs:
test:
strategy:
Expand All @@ -9,11 +20,6 @@ jobs:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Set Golang shared lib directory for GH Actions
run: |
echo "LD_LIBRARY_PATH=/tmp" >> $GITHUB_ENV
echo "PACT_GO_LIB_DOWNLOAD_PATH=/tmp" >> $GITHUB_ENV
echo "LOG_LEVEL=trace" >> $GITHUB_ENV
- name: Install Go
uses: actions/setup-go@v2
with:
Expand Down
27 changes: 24 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
include make/config.mk

TEST?=./...

.DEFAULT_GOAL := ci

ci:: docker deps clean bin test pact #goveralls
PACT_CLI="docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_USERNAME -e PACT_BROKER_PASSWORD -e PACT_BROKER_TOKEN pactfoundation/pact-cli:latest"

ci:: deps clean bin test pact #goveralls

# Run the ci target from a developer machine with the environment variables
# set as if it was on Travis CI.
# Use this for quick feedback when playing around with your workflows.
fake_ci:
@CI=true \
APP_SHA=`git rev-parse --short HEAD`+`date +%s` \
APP_BRANCH=`git rev-parse --abbrev-ref HEAD` \
make ci

# same as above, but just for pact
fake_pact:
@CI=true \
APP_SHA=`git rev-parse --short HEAD`+`date +%s` \
APP_BRANCH=`git rev-parse --abbrev-ref HEAD` \
make pact

docker:
@echo "--- 🛠 Starting docker"
Expand Down Expand Up @@ -43,8 +59,13 @@ install: bin
pact: clean install #docker
@echo "--- 🔨 Running Pact examples"
go test -v -tags=consumer -count=1 github.com/pact-foundation/pact-go/v2/examples/...
make publish
go test -v -timeout=10s -tags=provider -count=1 github.com/pact-foundation/pact-go/v2/examples/...

publish:
@echo "-- 📃 Publishing pacts"
@"${PACT_CLI}" publish ${PWD}/examples/pacts --consumer-app-version ${APP_SHA} --tag ${APP_BRANCH}

release:
echo "--- 🚀 Releasing it"
"$(CURDIR)/scripts/release.sh"
Expand Down
2 changes: 1 addition & 1 deletion consumer/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"unicode"
"unicode/utf8"

native "github.com/pact-foundation/pact-go/v2/internal/native/mockserver"
"github.com/pact-foundation/pact-go/v2/internal/native"
logging "github.com/pact-foundation/pact-go/v2/log"
"github.com/pact-foundation/pact-go/v2/models"
"github.com/pact-foundation/pact-go/v2/utils"
Expand Down
2 changes: 1 addition & 1 deletion consumer/interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"strings"

"github.com/pact-foundation/pact-go/v2/internal/native/mockserver"
mockserver "github.com/pact-foundation/pact-go/v2/internal/native"
"github.com/pact-foundation/pact-go/v2/matchers"
"github.com/pact-foundation/pact-go/v2/models"
"github.com/pact-foundation/pact-go/v2/utils"
Expand Down
4 changes: 2 additions & 2 deletions examples/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ func TestProductAPIClient(t *testing.T) {
// Specify the two applications in the integration we are testing
// NOTE: this can usually be extracted out of the individual test for re-use)
mockProvider, err := NewV2Pact(MockHTTPProviderConfig{
Consumer: "ProductAPIConsumer",
Provider: "ProductAPI",
Consumer: "PactGoProductAPIConsumer",
Provider: "PactGoProductAPI",
})
assert.NoError(t, err)

Expand Down
10 changes: 5 additions & 5 deletions examples/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestConsumerV2(t *testing.T) {
SetLogLevel("TRACE")

mockProvider, err := consumer.NewV2Pact(consumer.MockHTTPProviderConfig{
Consumer: "V2Consumer",
Consumer: "PactGoV2Consumer",
Provider: "V2Provider",
Host: "127.0.0.1",
TLS: true,
Expand Down Expand Up @@ -64,7 +64,7 @@ func TestConsumerV2_Match(t *testing.T) {
SetLogLevel("TRACE")

mockProvider, err := consumer.NewV2Pact(consumer.MockHTTPProviderConfig{
Consumer: "V2ConsumerMatch",
Consumer: "PactGoV2ConsumerMatch",
Provider: "V2ProviderMatch",
Host: "127.0.0.1",
TLS: true,
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestConsumerV3(t *testing.T) {
SetLogLevel("TRACE")

mockProvider, err := NewV3Pact(MockHTTPProviderConfig{
Consumer: "V3Consumer",
Consumer: "PactGoV3Consumer",
Provider: "V3Provider",
Host: "127.0.0.1",
TLS: true,
Expand Down Expand Up @@ -152,7 +152,7 @@ func TestConsumerV2AllInOne(t *testing.T) {
SetLogLevel("TRACE")

mockProvider, err := consumer.NewV2Pact(consumer.MockHTTPProviderConfig{
Consumer: "V2ConsumerAllInOne",
Consumer: "PactGoV2ConsumerAllInOne",
Provider: "V2Provider",
Host: "127.0.0.1",
TLS: true,
Expand Down Expand Up @@ -201,7 +201,7 @@ func TestMessagePact(t *testing.T) {
SetLogLevel("TRACE")

provider, err := NewMessagePactV3(MessageConfig{
Consumer: "V3MessageConsumer",
Consumer: "PactGoV3MessageConsumer",
Provider: "V3MessageProvider", // must be different to the HTTP one, can't mix both interaction styles
})
assert.NoError(t, err)
Expand Down
100 changes: 0 additions & 100 deletions examples/pacts/V2Consumer-V2Provider.json

This file was deleted.

100 changes: 0 additions & 100 deletions examples/pacts/V2ConsumerMatch-V2ProviderMatch.json

This file was deleted.

Loading