Something is wrong with parsing a table in grpcInt...
# protobufs
r
Something is wrong with parsing a table in grpcInteraction. The provider test always passes. Example grpcInteraction:
Copy code
"bulk_addresses": [
				{
					"id": "matching(type, '00000000-0000-0000-0000-000000000004')",
					"title": "matching(type, 'resTitle')",
					"first_name": "matching(type, 'resFirstName')",
					"middle_name": "matching(type, 'resMiddleName')",
					"address_line1": "matching(type, 'resAddressLie1')"
				}
]
When a field is set as
repeated
in proto file, the changes in consumer grpcInteraction does not have a impact on provider test. As soon as I remove the
[]
the test behaves as it should.
u
What is your expectation on the provider side? That the provider is not returning any examples, and it should fail?
r
I expect the provider to fail. Let me explain further. When I deliberately make the provider response with a data that is not matching data in the grpcInteraction then the provider fails only when in grpcInteraction the repeated field is defined without the the square brackets. e.g.
Copy code
"bulk_addresses": 
				{
					"id": "matching(type, '00000000-0000-0000-0000-000000000004')",
					"title": "matching(type, 'resTitle')",
					"first_name": "matching(type, 'resFirstName')",
					"middle_name": "matching(type, 'resMiddleName')",
					"address_line1": "matching(type, 'resAddressLie1')"
				}
But if I add the brackets, no matter how is the provider response data defined the test always passes.
u
Can you try plugin version 0.1.11, I put a fix in for using arrays to configure repeated fields.
r
Still the same. When I remove the brackets the test does return an error:
After adding the brackets: The test passes. There is only one instance of bulkaddress. And I know it is different than pact.json expect. Nevertheless the test passes.
u
Ok, are you using Pact-JS to run the test?
r
Pact-go@2.x.x
u
I'm having trouble replicating this. I always get an error if something is not correct.
Copy code
grpcInteraction := `{
		"pact:proto": "` + path + `",
		"pact:proto-service": "Calculator/calculateMulti",
		"pact:content-type": "application/protobuf",
		"request": {
			"shapes": [
				{
					"rectangle": {
						"length": "matching(number, 3)",
						"width": "matching(number, 4)"
					}
				},
				{
					"square": {
						"edge_length": "matching(number, 3)"
					}
				}
			]
		},
		"response": {
			"value": [
				{
					"id": "matching(regex, '\\d+', '1234')",
					"shape": "matching(type, 'rectangle')",
					"value": "matching(number, 12)"
				},
				{
					"id": "matching(type, '4')",
					"shape": "matching(type, 'square')",
					"value": "matching(number, 9)"
				}
			]
		}
	}`
On the provider side:
Copy code
Verifying a pact between grpc-consumer-go and area-calculator-provider

  calculate rectangle area request

  Given a Calculator/calculateMulti request
      with an input .area_calculator.AreaRequest message
      will return an output .area_calculator.AreaResponse message [FAILED]
    generates a message which
      has a matching body (FAILED)


Failures:

1) Verifying a pact between grpc-consumer-go and area-calculator-provider - calculate rectangle area request
    1.1) has a matching body
           $.value[0].id -> Expected '0abc' to match '\d+'

There were 1 pact failures
If I remove the square brackets, then I did notice that the paths for the matchers are not correct, but then I still get an error on the provider, just a different one
I.e.
Copy code
Failures:

1) Verifying a pact between grpc-consumer-go and area-calculator-provider - calculate rectangle area request
    1.1) has a matching body
           $.value[0].id -> Expected '1234' to be equal to '0abc'
           $.value -> Expected repeated field 'value' to have 1 values but received 2 values
           $.value[0].shape -> Expected 'rectangle' to be equal to 'box'
None of the matching rules are now applied
However, if I use a each value matcher, I do get the issue you have mentioned:
Copy code
"value": {
				"pact:match": "eachValue(matching($'area'))",
				"area": {
					"id": "matching(regex, '\\d+', '1234')",
					"shape": "matching(type, 'rectangle')",
					"value": "matching(number, 12)"
				}
			}
@Robert Henzel Ok, I think I have have fixed this issue. Updated plugin released 0.1.12
r
Omg, Thank your work, I did not notice you were writing here. Please feel free to mention me with @. Cause I was talking with Matt but totally missed your messages. I'll update to v 0.1.12 and will return with feedback.