Elaine Bernardino
01/19/2024, 4:32 AMpact-go
package in docker when running in a CI pipeline (in this case, buildkite)?
I've encountered issues saying that pact-go: command not found
but installed in in my Dockerfile and part of the Makefile
command which runs the container and installs the package within it. I'm still learning the ways of docker so there are some terms new to me
2024/01/19 00:57:52 [WARN] Usage of musl library is known to cause problems, prefer using glibc instead.
2024/01/19 00:57:52 [INFO] downloading library from <https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v0.4.5/libpact_ffi-linux-x86_64.so.gz> to /usr/local/lib/libpact_ffi.so
&{}
2024/01/19 00:57:54 [INFO] package libpact_ffi found
2024/01/19 00:57:54 [INFO] checking version 0.4.5 of libpact_ffi against semver constraint >= 0.4.0, < 1.0.0
2024/01/19 00:57:54 [INFO] package libpact_ffi is correctly installed
/bin/sh: line 2: pact-go: command not found
Here's the Dockerfile
FROM public.ecr.aws/docker/library/alpine:latest
RUN apk add --no-cache git make musl-dev go
RUN go version
# Configure Go
ENV GOROOT /usr/lib/go
ENV GOPATH /go
ENV PATH /go/bin:$PATH
RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin
# Install pact-go
RUN go install <http://github.com/pact-foundation/pact-go/v2@v2.0.2|github.com/pact-foundation/pact-go/v2@v2.0.2>
ENV GOPATH /go
ENV PATH /go/bin:$PATH
and the command to run the test
docker compose run go-builder-pact \
pact-go install -f && pact-go -l DEBUG install && go test -v -timeout 120s -count=1 ./tests/contract/... --tags=pact
Thank you!Matt (pactflow.io / pact-js / pact-go)
WARN
). It might work, it might fail spectacularly (i.e. segfault). A debian based distribution is usually a safer betMatt (pactflow.io / pact-js / pact-go)
ENV
command only sets the environment for the build stage. It won’t set it in the OS itself. For that, you’d need to add it to the user’s profile or another system locationMatt (pactflow.io / pact-js / pact-go)
RUN pact-go install -f && pact-go -l DEBUG install
to the end of your docker file?
Then the go test…
should just work, assuming the go environment is correctYousaf Nabi (pactflow.io)
Zeus
01/21/2024, 1:20 PMinstall-pact:
go install <http://github.com/pact-foundation/pact-go/v2@v2.0.2|github.com/pact-foundation/pact-go/v2@v2.0.2>
pact-go -l DEBUG install -d /tmp
ls -la /tmp/
Is it advisable to installing to /tmp on the developer machines? Or should I use docker instead? I understand that it will be slower if we use docker to run install/run pact tests..
Do you have any strong opinion on this?Rinka Yoshida
02/07/2024, 1:56 AMpact-go
when response body is empty. I suspect it's a bug and was wondering if you could help.
I see in the past that people have raised issue about allowing empty body: https://github.com/pact-foundation/pact-js/issues/177.
• pact-js is fixed to allow empty for both response and request
• pact-jvm is fixed as well for both
However, for pact-go
, it seemed like the fix was only for allowing empty request but not for empty response: https://github.com/pact-foundation/pact-go/commit/69125108ff7559355f088e8e16783bd3b09794f0
Curious if this is intentional or it's a potential bug?Hazem Borham
02/08/2024, 4:25 PMMatt (pactflow.io / pact-js / pact-go)
GitHub
02/13/2024, 7:18 AMissues
, pulls
, commits
, releases
, deployments
Matt (pactflow.io / pact-js / pact-go)
GitHub
02/13/2024, 7:19 AMpulls
, commits
, releases
, deployments
Matt (pactflow.io / pact-js / pact-go)
GitHub
02/13/2024, 7:19 AMpulls
, releases
, deployments
Matt (pactflow.io / pact-js / pact-go)
GitHub
02/13/2024, 7:19 AMMatt (pactflow.io / pact-js / pact-go)
GitHub
02/13/2024, 7:19 AMreleases
Christopher Tonog
02/14/2024, 9:29 PM% pact-go install -f -d /usr/local/lib
2024/02/14 16:16:29 [INFO] set lib dir target to /usr/local/lib
2024/02/14 16:16:29 [INFO] downloading library from <https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v0.4.16/libpact_ffi-osx-aarch64-apple-darwin.dylib.gz> to /usr/local/lib/libpact_ffi.dylib
2024/02/14 16:16:30 [ERROR] Your Pact library installation is out of date and we were unable to download a newer one for you: open /usr/local/lib/libpact_ffi.dylib: permission denied
A google search led me to this github issue: https://github.com/pact-foundation/pact-go/issues/239
Is it necessary to use sudo for this if I want to use the default dir? I ended up using /tmp
to get myself unblocked but read earlier that that is not advisable. Thanks for all the help thus far!Hristian Iliev
02/16/2024, 10:45 AMLogi Ragnarsson
02/18/2024, 9:44 AMLeonardo Galani
03/05/2024, 5:54 PM2024/03/05 18:47:19 [INFO] checking pact-mock-service within range >= 3.5.0, < 4.0.0
2024/03/05 18:47:19 [ERROR] CLI tools are out of date, please upgrade before continuing
Cannot find any related documentation on how to update this, as I'm using the latest version of everything pact-go related.
pact-go version 2.0.4
go version 1.22Kevin Taylor
03/07/2024, 4:45 PMStanislav Vodetskyi
03/08/2024, 4:00 AMEachKeyLike
?Alex Kaufman
03/28/2024, 3:43 PMRinka Yoshida
03/30/2024, 12:39 AM"my_struct_arr": map[string]interface{}{
"pact:match": "eachValue(matching($'element'))",
"element": map[string]interface{}{
"str": "matching(type, 'random')",
},
}
I can match an array of strings like this
"my_str_arr": "eachValue(matching(type, 'random'))"
But I cannot match an array of strings like this? It's giving me error Failed to call out to plugin - Request to configure interaction failed: Failed to process protobuf: Field values must be configured with a string value, got Object {"element": String("matching(type, 'random')"), "pact:match": String("eachValue(matching($'element'))")}
. Is matching array of primitive types different from array of structs?
"my_str_arr": map[string]interface{}{
"pact:match": "eachValue(matching($'element'))",
"element": "matching(type, 'random')",
}
2. Map Matching
Is there a way to match a map of string to structs, like the below? It's giving me error Failed to call out to plugin - Request to configure interaction failed: Failed to process protobuf: For message fields, you need to define a Map of expected fields, got String("matching(type, 'random')")
.
"my_str_struct_map": map[string]interface{}{
"pact:match": "eachKey(matching($'key')), eachValue(matching($'value'))",
"key": "matching(type, 'random')",
"value": map[string]interface{}{
"str": "matching(type, 'random')",
},
},
aofadero
04/16/2024, 8:40 PMCONSUMER_NAME
and PROVIDER_NAME
would be the relevant names e.g. UserConsumer
and UserProvider
. What values does one use for the LOG_DIR
and PACT_DIR
as I'm using pactfoundation/pact-broker
container with my development?
mockProvider, err := consumer.NewV2Pact(consumer.MockHTTPProviderConfig{
Consumer: os.Getenv("CONSUMER_NAME"),
Provider: os.Getenv("PROVIDER_NAME"),
LogDir: os.Getenv("LOG_DIR"),
PactDir: os.Getenv("PACT_DIR"),
})
aofadero
04/18/2024, 7:53 PM/usr/local/go/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: library not found for -lpact_ffi
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The code for the test is as follows
func TestEmailConsumer_CheckEmail2(t *testing.T) {
pact := dsl.Pact{
Consumer: "CheckEmailConsumer",
Provider: "CheckEmailProvider",
}
pact.Setup(true)
t.Run("Check if email exists", func(t *testing.T) {
email := "<mailto:pact_no_email2@example.com|pact_no_email2@example.com>"
headers := getRequestHeaders(***)
pact.
AddInteraction().
Given(fmt.Sprintf("An email %s that does not exist", email)).
UponReceiving(fmt.Sprintf("A request to check if the email '%s' exists", email)).
WithRequest(dsl.Request{
Method: "GET",
Path: dsl.Term(fmt.Sprintf(checkEmailsEndpoint, email), "/****/emails/[a-z]"),
Headers: dsl.MapMatcher{
"Content-Type": dsl.Term(headers["Content-Type"], `application\/json`),
"user-agent": dsl.Like(headers["user-agent"]),
},
}).
WillRespondWith(dsl.Response{
Status: 404,
Body: dsl.Like(TextNowResult{
Result: nil,
ErrorCode: "",
}),
})
err := pact.Verify(func() error {
host, _ := url.Parse(fmt.Sprintf("%s:%d", pact.Host, pact.Server.Port))
client := &Client{
BaseURL: host,
}
result, err := client.CheckEmail(email, TNAndroidClientType)
assert.Nil(t, result.Result)
assert.Nil(t, result.ErrorCode)
return err
})
assert.NoError(t, err)
})
}
Michael Strasser
04/19/2024, 5:33 AMaofadero
04/19/2024, 2:51 PMpact-go
cli version. When I check the version I get this (below), however when I run my test I get an error asking me to upgrade my CLI tool. How can I go about that?
pact-go version ──(Fri,Apr19)─┘
Pact Go CLI v2.0.0-beta.23%
// test error
2024/04/19 10:45:53 [INFO] checking pact-mock-service within range >= 3.5.0, < 4.0.0
2024/04/19 10:45:53 [ERROR] CLI tools are out of date, please upgrade before continuing