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

How can pact handle dynamic bits in URL and query params ? #72

Closed
mohanraj-r opened this issue Mar 21, 2018 · 3 comments
Closed

How can pact handle dynamic bits in URL and query params ? #72

mohanraj-r opened this issue Mar 21, 2018 · 3 comments

Comments

@mohanraj-r
Copy link
Contributor

I am trying to test a complex interaction :

  1. Issue a Get req against a specific path with a specific query parm - returns a result with a dynamic ref id
  2. Subsequent Post req against a path composed of the dynamic ref id obtained in step 1 to get a dynamic value
  3. Subsequent Get req against a static path with a query param constructed with the value obtained in step 2

How can I do this with Pact?

  • Tried using dsl.Like - but looks like its supported only for body ?

Software versions

Software versions

  • OS: Mac OSX 10.13.2
  • Consumer Pact library:
$ pact-go version
Pact Go CLI v0.0.11
  • Provider Pact library: v0.0.12
  • Golang Version: go1.10 darwin/amd64
  • Golang environment: Provide output of go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/mohanrajr/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mohanrajr/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/d0/742yxrrx0glg93s4z_rwyzkxm0whbv/T/go-build258382301=/tmp/go-build -gno-record-gcc-switches -fno-common"
@mefellows
Copy link
Member

Hi @mohanraj-r,

You are talking about functional testing, which is not something Pact supports. Each interaction must strictly be able to be validated in isolation from another. To achieve this, we use "provider states".

See https://docs.pact.io/best_practices/contract_tests_not_functional_tests.html for a discussion of these functional tests.

If I have misunderstood, and your request is more about being able to match the request path/headers/etc. using matchers, I've just come across a bug for that (related to a @gallamine query) and will release a fix in the next few days.

@mohanraj-r
Copy link
Contributor Author

mohanraj-r commented Mar 22, 2018

we use "provider states".

Thanks @mefellows
Can you give me an example of how to setup provider states in Go?
Looked at Provider States · Pact - but the examples are in Ruby - not clear how I can do the same in Go.

more about being able to match the request path/headers/etc. using matchers

Yes, having the ability to use matchers in the req URL, query etc could be helpful for me in this case as well

@mefellows
Copy link
Member

Have you looked at the examples? The mux example shows how to achieve this with the in-built http package.

The readme also explains this in the provider section.

Hope that helps.

mefellows added a commit that referenced this issue Mar 22, 2018
- Allows path, query and headers to contain Matchers
in order.
- Update integration test examples to demonstrate capability
- Speeds up test suite significantly

BREAKING CHANGE

Change updates the field definitions within the Request and
Response types (See MatcherMap and MatcherString).

Fixes #72, Fixes #73
mefellows added a commit that referenced this issue Mar 24, 2018
- Allows path, query and headers to contain Matchers
in order.
- Update integration test examples to demonstrate capability
- Speeds up test suite significantly

BREAKING CHANGE

Change updates the field definitions within the Request and
Response types (See MatcherMap and MatcherString).

Fixes #72, Fixes #73
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