I’m struggling to express the correct grpc interac...
# protobufs
r
I’m struggling to express the correct grpc interaction message in my test. With a proto file containing this:
Copy code
service LanguageRuntime {
    // About returns information about the runtime for this language.
    rpc About(google.protobuf.Empty) returns (AboutResponse) {}
}

// AboutResponse returns runtime information about the language.
message AboutResponse {
    string executable = 1; // the primary executable for the runtime of this language.
    string version = 2; // the version of the runtime for this language.
    map<string, string> metadata = 3; // other information about this language.
}
I have this as my
grpcInteration
object so far:
Copy code
grpcInteraction := `{
		"pact:proto": "` + filepath.ToSlash(dir) + `",
		"pact:proto-service": "LanguageRuntime/About",
		"pact:content-type": "application/protobuf",
		"request": {
		},
		"response": {
			"executable": "matching(type, 'pulumi')",
			"version": "matching(type, '3.48.0')",
			"metadata": {
				"matching(type, 'someKey')": "matching(type, 'somevalue')"
			}
		}
	}`
The error I get is this, and I get head nor tail to it:
Copy code
2022-12-13T14:51:19.060937Z ERROR ThreadId(01) pact_ffi::plugins: 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, 'somevalue')")
I tried various things already for the free form
metadata
field so far, but to no avail. I haven’t found any example which has a
map
in the proto file that I can copy from. What is the correct way to write this?
Or is this one of the unsupported features for now?
• Map fields with scalar keys.
https://github.com/pactflow/pact-protobuf-plugin#unsupported-features
u
I'll play around with it, see what is going on
thankyou 2
The correct form would be something like:
"metadata": "eachKey(matching(type, 'someKey')), eachValue(matching(type, 'somevalue'))"
thankyou 1
r
Code updated.