Hey :wave: We are trying to use pact for creating ...
# pact-go
t
Hey 👋 We are trying to use pact for creating contracts for kinesis events, the consumer listens for proto’s that are sent through. We are creating matchers using similar code as below:
Copy code
WithContent(map[string]interface{}{
			"moneyToMove":           term(),
}).WithType(&myproto.MyProtoName)
The issue we are running into is that the unmarshaller is not able to unmarshal to proto types. Is there some methods that can be overriden to achieve this? The error that we end up getting is:
Copy code
VerifyMessageConsumer failed: unable to narrow type to : json: cannot unmarshal string into Go struct field myproto.created_at of type timestamppb.Timestamp
m
We actually do support protobufs in the latest https://github.com/pact-foundation/pact-go/tree/2.x.x version. However I don’t have an example there for you yet (the gRPC is probably closest, if that’s what you need).
You can’t specify a custom unmarshaller, because we use a shared core that needs to be aware of it.
Support is via plugins, and specifically this plugin
s
thanks, we can look into integrating with 2.x.x. For our use-case we do not need gRPC as the events flow through kinesis
m
sorry, you did say kinesis - did I mention I just got back to Australia after a trip to US (aka I’m blaming jetlag 😆 )
🤣 2
s
it seems we need the proto file to be available with this new approach. in our case we have the proto schema in a central place which is responsible for generating the models. in the project we just import the generated models. Also, the proto message refers to types in other proto files, not sure how to provide this to the plugin. Any guidance on how to work with this setup?
m
At this stage we need the proto file at test time. I think tools exist to resolve references (e.g. buf.build). Could you download from the central place?
s
thanks for the suggestion. We can download the proto files. Will look into other suggestion as well
👍 1
m
Thanks - let us know how you go!