Becca Liss
08/05/2024, 3:33 PMstruct
field, e.g.
message Request {
string name = 1;
google.protobuf.Struct params = 2;
}
In my test, I am creating a new struct
params, err := structpb.NewStruct(map[string]any{"kind": "general", "message": "test" })
and then marshaling it to JSON. The string I am passing to withContents
looks like this
{
"pact:proto": "whatever.proto",
"pact:proto-service": "Service/Endpoint",
"pact:content-type": "application/protobuf",
"request": {
"name": "name",
"params": {
"kind": "general",
"message": "test"
}
},
"response": {
"responses": [
{
"success": true,
"id": "test123"
}
]
}
}
I run the test once and get this error
Received generate templates error rpc error: code = FailedPrecondition desc = Failed to match the request message - BodyMismatches({"$.params": [BodyMismatch { path: "$.params.fields.key", expected: Some(b"\"message\""), actual: Some(b"\"kind\""), mismatch: "Expected 'kind' (String) to be equal to 'message' (String)" }, BodyMismatch { path: "$.params.fields.value.string_value", expected: Some(b"\"test\""), actual: Some(b"\"general\""), mismatch: "Expected 'general' (String) to be equal to 'test' (String)" }]})
and then I run the test again (changing nothing, with exact same contents string) and it passesBecca Liss
08/05/2024, 3:34 PMrholshausen
08/05/2024, 11:17 PMBecca Liss
08/07/2024, 1:08 PMmatching
code but didn't get very far. I also looked into the matching docs to see if there was something I could use there, but it seems like that's geared more towards primitives. We have a bunch of teams using google.protobuf.Struct
in their proto files, so this is a pretty big blocker for us 😕rholshausen
08/07/2024, 11:13 PMMatt (pactflow.io / pact-js / pact-go)
Becca Liss
08/08/2024, 1:27 PMBecca Liss
08/08/2024, 1:36 PM