Skip to content

Commit

Permalink
Merge branch 'master' into feat/graphql-support
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Jun 27, 2022
2 parents c924c86 + 583fe15 commit 4eb1a45
Show file tree
Hide file tree
Showing 55 changed files with 8,744 additions and 338 deletions.
7,746 changes: 7,745 additions & 1 deletion .github/pact-small.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Do this to generate your change history

## Versions

### v1.6.9 (09 February 2022)
* [25a5ad5](https://github.com/pact-foundation/pact-go/commit/25a5ad5) - Match should skip unexported fields as they won't be serialized (#201) (Cody A. Ray, Tue Feb 8 21:07:54 2022 -0600)

### v1.6.8 (04 February 2022)
* [18c791e](https://github.com/pact-foundation/pact-go/commit/18c791e) - fix: support struct tags for pointers (Sonia Hamilton, Tue Feb 1 10:31:07 2022 +1100)
* [0360e55](https://github.com/pact-foundation/pact-go/commit/0360e55) - refactor(all): Small refactor (#193) (Sasha Melentyev, Sun Dec 26 15:44:11 2021 +0300)
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at pact-support@googlegroups.com. All
reported by contacting the project team at pact-foundation@googlegroups.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.16
FROM golang:1.17.8

# Install pact ruby standalone binaries
RUN curl -LO https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.88.78/pact-1.88.78-linux-x86_64.tar.gz; \
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ docker:

bin:
gox -os="darwin" -arch="amd64" -output="build/pact-go_{{.OS}}_{{.Arch}}"
gox -os="darwin" -arch="arm64" -output="build/pact-go_{{.OS}}_{{.Arch}}"
gox -os="windows" -arch="386" -output="build/pact-go_{{.OS}}_{{.Arch}}"
gox -os="linux" -arch="386" -output="build/pact-go_{{.OS}}_{{.Arch}}"
gox -os="linux" -arch="amd64" -output="build/pact-go_{{.OS}}_{{.Arch}}"
Expand All @@ -30,7 +31,7 @@ deps:

install:
@if [ ! -d pact/bin ]; then\
@echo "--- 🐿 Installing Pact CLI dependencies"; \
echo "--- 🐿 Installing Pact CLI dependencies"; \
curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | bash -x; \
fi

Expand Down
37 changes: 16 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Read [Getting started with Pact] for more information for beginners.
- [Versions](#versions)
- [Installation](#installation)
- [Go get](#go-get)
- [Installation on \*nix](#installation-on-\nix)
- [Installation on \*nix](#installation-on-nix)
- [V3 Beta](#v3-beta)
- [Using Pact](#using-pact)
- [HTTP API Testing](#http-api-testing)
Expand Down Expand Up @@ -80,12 +80,7 @@ Read [Getting started with Pact] for more information for beginners.
- [HTTP APIs](#http-apis)
- [Asynchronous APIs](#asynchronous-apis)
- [Integrated examples](#integrated-examples)
- [Troubleshooting](#troubleshooting)
- [Splitting tests across multiple files](#splitting-tests-across-multiple-files)
- [Output Logging](#output-logging)
- [Check if the CLI tools are up to date](#check-if-the-cli-tools-are-up-to-date)
- [Disable CLI checks to speed up tests](#disable-cli-checks-to-speed-up-tests)
- [Re-run a specific provider verification test](#re-run-a-specific-provider-verification-test)
- [Troubleshooting](#troubleshooting) - [Splitting tests across multiple files](#splitting-tests-across-multiple-files) - [Output Logging](#output-logging) - [Check if the CLI tools are up to date](#check-if-the-cli-tools-are-up-to-date) - [Disable CLI checks to speed up tests](#disable-cli-checks-to-speed-up-tests) - [Re-run a specific provider verification test](#re-run-a-specific-provider-verification-test)
- [Verifying APIs with a self-signed certificate](#verifying-apis-with-a-self-signed-certificate)
- [Testing AWS API Gateway APIs](#testing-aws-api-gateway-apis)
- [Contact](#contact)
Expand All @@ -94,13 +89,14 @@ Read [Getting started with Pact] for more information for beginners.
- [Contributing](#contributing)

<!-- /TOC -->

## Versions

<details><summary>Specification Compatibility</summary>

| Version | Stable | [Spec] Compatibility | Install |
|---------|--------|----------------------|--------------------|
| 2.x.x | Beta | 2, 3 | See [v2.x.x] |
| ------- | ------ | -------------------- | ------------------ |
| 2.x.x | Beta | 2, 3 | See [v2.x.x] |
| 1.0.x | Yes | 2, 3\* | See [installation] |
| 0.x.x | Yes | Up to v2 | 0.x.x [stable] |

Expand Down Expand Up @@ -442,21 +438,22 @@ for different test cases:
_Important Note_: You should only use this feature for things that can not be persisted in the pact file. By modifying the request, you are potentially modifying the contract from the consumer tests!

#### Pending Pacts

_NOTE_: This feature is currently only available on [Pactflow]

Pending pacts is a feature that allows consumers to publish new contracts or changes to existing contracts without breaking Provider's builds. It does so by flagging the contract as "unverified" in the Pact Broker the first time a contract is published. A Provider can then enable a behaviour (via `EnablePending: true`) that will still perform a verification (and thus share the results back to the broker) but _not_ fail the verification step itself.
This enables safe introduction of new contracts into the system, without breaking Provider builds, whilst still providing feedback to Consumers as per before.
See the [docs](https://docs.pact.io/pending) and this [article](http://blog.pact.io/2020/02/24/how-we-have-fixed-the-biggest-problem-with-the-pact-workflow/) for more background.
See the [docs](https://docs.pact.io/pending) and this [article](https://docs.pact.io/blog/2020/02/24/how-weve-fixed-the-biggest-problem-with-the-pact-workflow) for more background.
#### WIP Pacts
_NOTE_: This feature is currently only available on [Pactflow]
WIP Pacts builds upon pending pacts, enabling provider tests to pull in _any_ contracts applicable to the provider regardless of the `tag` it was given. This is useful, because often times consumers won't follow the exact same tagging convention and so their workflow would be interrupted. This feature enables any pacts determined to be "work in progress" to be verified by the Provider, without causing a build failure. You can enable this behaviour by specifying a valid `time.Time` field for `IncludeWIPPactsSince`. This sets the start window for which new WIP pacts will be pulled down for verification, regardless of the tag.

See the [docs](https://docs.pact.io/wip) and this [article](http://blog.pact.io/2020/02/24/introducing-wip-pacts/) for more background.
See the [docs](https://docs.pact.io/wip) and this [article](https://docs.pact.io/blog/2020/02/24/introducing-wip-pacts) for more background.

#### Lifecycle of a provider verification

Expand All @@ -472,7 +469,7 @@ Using a [Pact Broker] is recommended for any serious workloads, you can run your

By integrating with a Broker, you get much more advanced collaboration features and can take advantage of automation tools, such as the [can-i-deploy tool], which can tell you at any point in time, which component is safe to release.

See the [Pact Broker](https://docs.pact.io/getting-started/sharing-pacts-with-the-pact-broker)
See the [Pact Broker](https://docs.pact.io/getting_started/sharing_pacts)
documentation for more details on the Broker.

#### Publishing from Go code
Expand All @@ -489,7 +486,7 @@ err := p.Publish(types.PublishRequest{

#### Publishing Provider Verification Results to a Pact Broker

If you're using a Pact Broker (e.g. a hosted one at pact.dius.com.au), you can
If you're using a Pact Broker (e.g. a hosted one at pactflow.io), you can
publish your verification results so that consumers can query if they are safe
to release.
Expand Down Expand Up @@ -574,10 +571,8 @@ var userHandlerWrapper = func(m dsl.Message) error {
// 3 Create the Pact Message Consumer
pact := dsl.Pact {
return dsl.Pact{
Consumer: "PactGoMessageConsumer",
Provider: "PactGoMessageProvider",
}
Consumer: "PactGoMessageConsumer",
Provider: "PactGoMessageProvider",
}
// 4 Write the consumer test, and call VerifyMessageConsumer
Expand All @@ -594,7 +589,7 @@ func TestMessageConsumer_Success(t *testing.T) {
"access": eachLike(map[string]interface{}{
"role": term("admin", "admin|controller|user"),
}, 3),
})
}).
AsType(&User{}) // Optional
pact.VerifyMessageConsumer(t, message, userHandlerWrapper)
Expand Down Expand Up @@ -719,7 +714,7 @@ This example will result in a response body from the mock server that looks like
Often times, you find yourself having to re-write regular expressions for common formats. We've created a number of them for you to save you the time:

| method | description |
|-----------------|-------------------------------------------------------------------------------------------------|
| --------------- | ----------------------------------------------------------------------------------------------- |
| `Identifier()` | Match an ID (e.g. 42) |
| `Integer()` | Match all numbers that are integers (both ints and longs) |
| `Decimal()` | Match all real numbers (floating point and decimal) |
Expand Down Expand Up @@ -948,8 +943,8 @@ See [CONTRIBUTING](https://github.com/pact-foundation/pact-go/edit/master/CONTRI
[message support]: https://github.com/pact-foundation/pact-specification/tree/version-3#introduces-messages-for-services-that-communicate-via-event-streams-and-message-queues
[changelog]: https://github.com/pact-foundation/pact-go/blob/master/CHANGELOG.md
[pact broker]: https://github.com/pact-foundation/pact_broker
[hosted broker]: https://pact.dius.com.au
[hosted broker]: https://pactflow.io
[can-i-deploy tool]: https://docs.pact.io/can_i_deploy
[Pactflow]: https://pactflow.io
[pactflow]: https://pactflow.io
[v2.x.x]: https://github.com/pact-foundation/pact-go/tree/2.x.x
[slack]: https://slack.pact.io
2 changes: 1 addition & 1 deletion command/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/spf13/cobra"
)

var version = "v1.6.8"
var version = "v1.7.0"
var cliToolsVersion = "1.82.3"
var versionCmd = &cobra.Command{
Use: "version",
Expand Down
4 changes: 4 additions & 0 deletions dsl/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ func match(srcType reflect.Type, params params) Matcher {

for i := 0; i < srcType.NumField(); i++ {
field := srcType.Field(i)
// Skip unexported fields.
if field.PkgPath != "" {
continue
}
fieldName := getJsonFieldName(field)
if fieldName == "" {
continue
Expand Down
10 changes: 10 additions & 0 deletions dsl/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,9 @@ func TestMatch(t *testing.T) {
Word string `json:"word"`
WordDash string `json:"-,"`
}
type unexportedDTO struct {
unexported string //nolint
}
str := "str"
type args struct {
src interface{}
Expand Down Expand Up @@ -752,6 +755,13 @@ func TestMatch(t *testing.T) {
"-": Like("string"),
},
},
{
name: "recursive case - struct with unexported field",
args: args{
src: unexportedDTO{},
},
want: StructMatcher{},
},
{
name: "base case - string",
args: args{
Expand Down
2 changes: 1 addition & 1 deletion dsl/pact.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ func (p *Pact) VerifyMessageConsumerRaw(message *Message, handler MessageConsume
})
}

// VerifyMessageConsumer is a test convience function for VerifyMessageConsumerRaw,
// VerifyMessageConsumer is a test convenience function for VerifyMessageConsumerRaw,
// accepting an instance of `*testing.T`
func (p *Pact) VerifyMessageConsumer(t *testing.T, message *Message, handler MessageConsumer) error {
err := p.VerifyMessageConsumerRaw(message, handler)
Expand Down
2 changes: 1 addition & 1 deletion examples/mux/provider/reports/pacts/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@

- Ask a question on stackoverflow and tag it `pact-ruby`

Tried to retrieve diff with previous pact from https://test.pact.dius.com.au/pacts/provider/loginprovider/consumer/jmarie/version/1.0.0/diff/previous-distinct, but received response code 401 Unauthorized.
Tried to retrieve diff with previous pact from https://test.pactflow.io/pacts/provider/loginprovider/consumer/jmarie/version/1.0.0/diff/previous-distinct, but received response code 401 Unauthorized.
10 changes: 7 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ module github.com/pact-foundation/pact-go
go 1.12

require (
github.com/gin-gonic/gin v1.7.2
github.com/gin-gonic/gin v1.7.7
github.com/golang/protobuf v1.4.2 // indirect
github.com/graph-gophers/graphql-go v1.3.0
github.com/hashicorp/go-version v1.3.0
github.com/hashicorp/go-version v1.5.0
github.com/hashicorp/logutils v1.0.0
github.com/hasura/go-graphql-client v0.6.3
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/json-iterator/go v1.1.10 // indirect
github.com/klauspost/compress v1.14.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/spf13/cobra v1.1.3
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.7.4
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/protobuf v1.25.0 // indirect
Expand Down
Loading

0 comments on commit 4eb1a45

Please sign in to comment.