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

Allow .WithMetadata function to use pact DSL rather than static values #217

Open
nsfrias opened this issue Jun 16, 2022 · 2 comments
Open

Comments

@nsfrias
Copy link

nsfrias commented Jun 16, 2022

Software versions

  • OS: Mac OSX 12.3.1
  • Consumer Pact library: v2.0.0-beta.11
  • Provider Pact library: v2.0.0-beta.11
  • Golang Version: go version go1.18.3 darwin/arm6
  • Golang environment:
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/nunofrias/Library/Caches/go-build"
GOENV="/Users/nunofrias/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/nunofrias/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/nunofrias/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.18.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.18.3/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.18.3"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/nunofrias/Documents/repos/reseller-entitlement-service/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zn/48yhvjqd17z0x_qy9y6bqn080000gn/T/go-build3642680703=/tmp/go-build -gno-record-gcc-switches -fno-common"

Expected behaviour

WithMetadata method of github.com/pact-foundation/pact-go/v2/message should accept Pact DSL as argument (something like map[string]Matcher similarly to WithJSONContent) to allow us to set an expectation for metadata properties that are not static -- for example a timestamp.

Actual behaviour

WithMetadata method of github.com/pact-foundation/pact-go/v2/message only accepts a map[string]string thus allowing us to define only static metadata properties.

@nsfrias nsfrias changed the title Allow Pact .WithMetadata function to use pact DSL rather than static values Allow .WithMetadata function to use pact DSL rather than static values Jun 16, 2022
@nsfrias
Copy link
Author

nsfrias commented Jun 30, 2022

Working on this.

@nsfrias
Copy link
Author

nsfrias commented Jul 1, 2022

Hi,

After some investigation I found that the pact_ffi rust library needs to be changed to allow metadata to include matchers, the changes that need to happen in my view are:

  • change the pactffi_message_with_metadata function (in pact_ffi/src/mock_server/handles.rs)to include the metadata rules in the Pact matchingRules section
  • change the pactffi_message_reify function (in pact_ffi/src/mock_server/handles.rs) to reify the metadata values (right now it only handles the contents)

In addition to this a very minor change is required in WithMetadata function in pact-go/internal/native/message_server.go to build the matching rule (using stringFromInterface()).

The rust changes will take me a bit as I am yet not very familiar with it. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants