Shakil Riyad
11/25/2024, 9:57 PMMarcus Couto
11/25/2024, 10:53 PMDilip Punna
11/29/2024, 9:26 AMMarcus Couto
11/29/2024, 3:31 PMprovider
validation, I can only see if there is any pact failing if I run the tests in debug mode. Is that the expected behaviour, or am I missing something? For example, the first screenshot is what I get when I just ârun testsâ in VS Code, and the second is when I âdebug testâ. This means that a dev from the provider side would only notice something is wrong if they run the tests in debug mode.Luis NuĂąo
11/29/2024, 5:40 PMproduces:
- application/json
- image/jpeg
- image/png
- application/octet-stream
On the consumer side we are writing a test that expects a `"Content-Type": "application/json"`:
WillRespondWith(200, func(b *consumer.V2ResponseBuilder) {
b.Header("Content-Type", Regex("application/json", "application/json;?.*"))
}).
But when we publish the contract to PactFlow we get the next error:
Validator Error
schema is invalid: data/type must be equal to one of the allowed values, data/type must be array, data/type must match a schema in anyOf
Since this swagger 2.0 anyOf
is not supported, so is there any way we can fix this issue?Yunzhao Xu
12/02/2024, 11:58 PM{a: "aaa"}
on December 5th, {b: "bbb"}
on the 8th, and {a: "ccc"}
on the 9th. I'd like to know:
⢠Do I need to include the above logics in the contract testing? Should all functional changes be included or only when the structure changes from a
to b
?
⢠How should such conditional changes that return different results be handled in contract testing? Do I need to mock the server side? If mock is needed, should it be done at a relatively earlier position, like directly mocking in the Controller, or at a relatively later position, such as inserting several test data into the database in the dev environment? And how should the situation related to time be dealt with?
⢠Where can I learn the knowledge about this kind of writing practice?
thanksJacob Buckley
12/05/2024, 12:25 AMtime.Time
appears to not be mocked correctly with BodyMatch
I can minimally reproduce this issue with the following:
func TestPact(t *testing.T) {
mockProvider, err := consumer.NewV4Pact(
consumer.MockHTTPProviderConfig{
Consumer: "consumer",
Provider: "provider",
},
)
require.NoError(t, err)
type TimeStruct struct {
Time time.Time `json:"time"`
}
err = mockProvider.AddInteraction().
Given("anything").
UponReceiving("A request for the current time").
WithRequest(http.MethodGet, "/time", func(builder *consumer.V4RequestBuilder) {}).
WillRespondWith(
http.StatusOK,
func(builder *consumer.V4ResponseBuilder) {
builder.BodyMatch(
TimeStruct{},
)
},
).
ExecuteTest(
t, func(config consumer.MockServerConfig) error {
resp, err := http.Get(fmt.Sprintf("<http://%s:%d/time>", config.Host, config.Port))
require.NoError(t, err)
b, err := io.ReadAll(resp.Body)
require.NoError(t, err)
var timeStruct TimeStruct
err = json.Unmarshal(b, &timeStruct)
assert.NoError(t, err, string(b))
return err
},
)
assert.NoError(t, err)
}
which has the following output
=== RUN TestPact
2024-12-05T00:22:22.417160Z INFO tokio-runtime-worker pact_mock_server::hyper_server: Received request GET /time
2024-12-05T00:22:22.417281Z INFO tokio-runtime-worker pact_mock_server::hyper_server: Request matched, sending response
pact_test.go:59:
Error Trace: /Users/buckley/dev/[redacted]/pkg/api/pact/pact_test.go:59
/Users/buckley/go/pkg/mod/github.com/pact-foundation/pact-go/v2@v2.0.8/consumer/http.go:152
/Users/buckley/go/pkg/mod/github.com/pact-foundation/pact-go/v2@v2.0.8/consumer/http_v4.go:319
/Users/buckley/dev/[redacted]/pkg/api/pact/pact_test.go:50
Error: Received unexpected error:
Time.UnmarshalJSON: input is not a JSON string
Test: TestPact
Messages: {"time":{"":{"":{"":true}}}}
2024/12/04 17:22:22 [ERROR] failed to log to stdout: can't set logger (applying the logger failed, perhaps because one is applied already).
pact_test.go:63:
Error Trace: /Users/buckley/dev/[redacted]/pkg/api/pact/pact_test.go:63
Error: Received unexpected error:
Time.UnmarshalJSON: input is not a JSON string
Test: TestPact
--- FAIL: TestPact (0.01s)
FAIL
You will note that the json returned is {"time":{"":{"":{"":true}}}}
instead of something like {"time":"2024-12-04T17:24:03.987Z"}
Yunzhao Xu
12/05/2024, 12:44 AMpact:proto
. Can this be ignored or bypassed in some other way?
path := fmt.Sprintf("%s/routeguide/route_guide.proto", strings.ReplaceAll(dir, "\\", "/"))
grpcInteraction := `{
"pact:proto": "` + path + `",
"pact:proto-service": "RouteGuide/GetFeature",
"pact:content-type": "application/protobuf",
"request": {
"latitude": "matching(number, 180)",
"longitude": "matching(number, 200)"
},
"response": {
"name": "notEmpty('Big Tree')",
"location": {
"latitude": "matching(number, 180)",
"longitude": "matching(number, 200)"
}
}
}`
Yunzhao Xu
12/05/2024, 7:08 AMERROR ThreadId(19) pact_mock_server::server_manager: Failed to shutdown plugin mock server with ID 624657c5-7383-47d9-8ef2-3b757700e648 - transport error
Is there any idea?Yunzhao Xu
12/08/2024, 1:00 PMMessageVerifier
and ProviderStateV3Response
cannot be found. Is there a problem with the document or my usage? Where should I look for a suitable example?Pietro Di Bello
12/17/2024, 11:22 AMKevser
01/06/2025, 3:39 PMWithRequest(http.MethodPost, url, func(b *consumer.V4RequestBuilder) {
b.Body(contentType, content)
}).
Error:
Mismatch with header 'Content-Type': Expected header 'Content-Type' to have value 'multipart/form-data;boundary=a76648f32eda23feef43a81954d35cbd782294c16f488baef7acbda53e32' but was 'multipart/form-data; boundary=325ce599ed0e830d149d04fa6be3c58835aa1bb7f8d31cb22d2514534999'
is there a way to use the Body method without specifying a contentType to avoid boundary mismatches? Thanks.Kevser
01/15/2025, 2:50 PMerr = mockProvider.
AddInteraction().
Given("a valid send log").
WithRequestPathMatcher(http.MethodPost, matchers.S(url), func(b *consumer.V4RequestBuilder) {
b.
Header("Content-Type", matchers.Like(contentType)).
MultipartBody(contentType, PactTaskID, "taskId").
MultipartBody("application/zip", zipFile, "file")
}).
GitHub
01/21/2025, 11:03 AMGitHub
01/21/2025, 11:54 AMGitHub
01/21/2025, 12:06 PMGitHub
01/21/2025, 4:00 PMRishav Singh
01/22/2025, 10:07 AM/usr/bin/ld: cannot find -lpact_ffi: No such file or directory
collect2: error: ld returned 1 exit status
can you please help to fix this ?Tom Lopez
01/22/2025, 4:04 PMGitHub
01/23/2025, 3:07 PMSudhir Meena
01/28/2025, 11:19 AMMatt (pactflow.io / pact-js / pact-go)
Sudhir Meena
01/28/2025, 12:28 PMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Dominic Plourde
01/30/2025, 7:48 PMpact_verifier: Failed to load pact - Failed to load pact from '<https://pact-broker.spatium-iot.com>': Error with the content of a HAL resource - Expected either a "*" or path identifier in path expression "$.query.$" at index 8
when we use one of those selector:
⢠DeployedOrReleased
⢠Environment
⢠Deployed
We tried a lot of possibilities, but only âLatest: trueâ works. since we have multiple environments, we also want DeployedOrReleased, which was working until recentlyRomain LĂŠtendart
01/31/2025, 4:56 PMFabian Noll
02/03/2025, 6:00 AM{
"providerName": "MQTTProducer",
"providerApplicationVersion": "1.0.0",
"success": true,
"verificationDate": "2025-02-03T05:54:37+00:00",
"testResults": [
{
"interactionId": "4502629169ea07b9fd7c9fd70c772553a1b4407d",
"success": true
}
],
"verifiedBy": {
"implementation": "Pact-Rust",
"version": "1.2.5"
},
"_links": {
"self": {
"title": "Verification result",
"name": "Verification result 201 for Pact between MQTTConsumer (1.0.1) and MQTTProducer",
"href": "<http://localhost:9292/pacts/provider/MQTTProducer/consumer/MQTTConsumer/pact-version/cd421621766dde56e9e01a0c8a8b47c4b5f63b40/verification-results/201>"
},
"pb:pact-version": {
"title": "Pact",
"name": "Pact between MQTTConsumer (1.0.1) and MQTTProducer",
"href": "<http://localhost:9292/pacts/provider/MQTTProducer/consumer/MQTTConsumer/pact-version/cd421621766dde56e9e01a0c8a8b47c4b5f63b40/metadata/Y3ZuPTEuMC4x>"
},
"pb:triggered-webhooks": {
"title": "Webhooks triggered by the publication of this verification result",
"href": "<http://localhost:9292/pacts/provider/MQTTProducer/consumer/MQTTConsumer/pact-version/cd421621766dde56e9e01a0c8a8b47c4b5f63b40/verification-results/201/triggered-webhooks>"
}
}
}
Devin Woods
02/05/2025, 8:58 PMUndefined symbols for architecture arm64:
"_pactffi_with_metadata", referenced from:
__cgo_b3f3fec7e6e1_Cfunc_pactffi_with_metadata in 000003.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Anyone ever see this before?Spencer
02/11/2025, 3:34 PM