Matt (pactflow.io / pact-js / pact-go)
Yu Xie
05/15/2023, 11:37 PMAsynchronousMessage.Contents
manually to protobuf and then verify that?Yu Xie
05/16/2023, 12:21 AMWithPlugin
), you can’t use AsType
and ConsumedBy
Matt (pactflow.io / pact-js / pact-go)
AsType
makes sense, because how would the framework know how to arbitrary convert a plugin’s contents to a narrow type?
ConsumedBy
is replaced by ExecuteTest
Matt (pactflow.io / pact-js / pact-go)
Yu Xie
05/16/2023, 1:23 AMConsumedBy
with // Deprecated: Use ExecuteTest instead.
then to avoid confusions.Matt (pactflow.io / pact-js / pact-go)
Yu Xie
05/27/2023, 12:07 AMfunc(states []models.ProviderState) (message.Body, message.Metadata, error)
Here message.Body
is an interface — what shall I give here? I tried both the proto Golang body, and deserialized []byte
, they both throwYu Xie
05/27/2023, 12:10 AMYu Xie
05/31/2023, 7:10 PMapplication/json; charset=utf-8
, while pact expects it to be something like application/protobuf; message=ProtoMessageExample
.
I guess it means protobuf plugin won’t work with provider verification through message handler?Yu Xie
05/31/2023, 7:50 PM2023-05-31T19:49:05.104537Z DEBUG ThreadId(01) verify_interaction{interaction="XXX"}: pact_matching: No content matcher defined for content type 'application/protobuf;message=SessionStatusResponse', using core matcher implementation
2023-05-31T19:49:05.104581Z DEBUG ThreadId(01) verify_interaction{interaction="async health information"}: pact_matching: No body matcher defined for content type 'application/protobuf;message=SessionStatusResponse', using plain text matcher
Yu Xie
05/31/2023, 9:40 PMAddAsynchronousMessage
) is missing plugin information.
Unlike sync message, the async message doesn’t have plugins
and raw proto desciptors under metadata
. Also, pactSpecification.version
is 3.0
for async contract, (instead of 4.0
for sync grpc contracts).
That might be why the provider side can’t find the matcher from the plugin I guess.Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Copy code2023-05-31T19:49:05.104537Z DEBUG ThreadId(01) verify_interaction{interaction="XXX"}: pact_matching: No content matcher defined for content type 'application/protobuf;message=SessionStatusResponse', using core matcher implementation
hmm interesting. I suspect the plugin only registers
application/protobuf
and because of the additional field it’s mis matching (guess).
What happens if you hard code application/protobuf
as the content type? I wonder if that goes a little further (but then probably fails due to the missing qualifier).Matt (pactflow.io / pact-js / pact-go)
Hmm good point. I think we will need a variation on this that allows aCopy codefunc(states []models.ProviderState) (message.Body, message.Metadata, error)
[]byte
to be returned here, and if a plugin is being used in an interaction, we use the different typed interface to signal that we require a byte array. We may also need to capture a content type here (or elsewhere) that is used to set the response mime typeMatt (pactflow.io / pact-js / pact-go)
Yu Xie
06/01/2023, 5:17 PMapplication/protobuf
and message name as content type header.
But eventually, pact is still falling back to plain text matcher which obviously doesn’t work. My guess is it’s because the generated contract doesn’t even include any plugin information and proto details on the consumer sideYu Xie
06/01/2023, 5:21 PM{
"metadata": {
"pactRust": {
"ffi": "0.4.1",
"mockserver": "1.0.0",
"models": "1.0.4"
},
"pactSpecification": {
"version": "4.0"
},
"plugins": [
{
"name": "protobuf",
"version": "0.3.0",
"configuration": "..."
}
]
}
}
While the async generated contract has metadata like this:
"metadata": {
"pactRust": {
"ffi": "0.4.1",
"models": "1.0.4"
},
"pactSpecification": {
"version": "3.0.0"
}
}
In addition to spec version being 3.0.0, it also misses plugin informationYu Xie
06/01/2023, 5:24 PMp.AddAsynchronousMessage().
GivenWithParameter(...).
ExpectsToReceive("...").
UsingPlugin(message.PluginConfig{
Plugin: "protobuf",
Version: "0.3.0",
}).
WithContents("...", "application/protobuf").
ExecuteTest(...)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Yu Xie
06/20/2023, 10:36 PMI’ll aim to create an example next week to test it out myself@Matt (pactflow.io / pact-js / pact-go) Checking back on this thread — is there an e2e working example now?
Matt (pactflow.io / pact-js / pact-go)
Yu Xie
07/10/2023, 11:55 PMYu Xie
07/10/2023, 11:58 PM