Open mark-onenetwork opened 3 years ago
The query matching logic is a nightmare, because there are many different ways a query can be parsed. I'm afraid you'll need to try using a string query expectation in this case.
@bethesque Thanks for the quick response. Then it's a "know issue". Could you please explain a bit more on using string query expectation instead? Would be appreciated, I'm not Ruby expert.
Can you please copy your Pact expectation code into a comment.
$request = new ConsumerRequest();
$request
->setMethod('GET')
->setPath('/api/products/my_endpoint?key_a[]=1&key_b[1]=2')
->addHeader('Content-Type', 'application/json');
It's in PHP, probably no way to do that.
Ah, it's already a string. Is there no separate method to set the query? In the other languages, the path and the query are set separately, so that suggests to me that something in the php is splitting them out.
Yes, there is a separate method to set the query.
$request = new ConsumerRequest();
$request
->setMethod('GET')
->setPath('/api/products/my_endpoint')
->setQuery('key_a[]=1&key_b[1]=2')
->addHeader('Content-Type', 'application/json');
Needs retesting in pact-php 10.x which utilises the pact reference core in rust via ffi, rather than the pact ruby project
Hi All,
I encountered a weird issue: verification failed when the query has nested keys
key_a[]=1&key_b[1]=2
, key_a is an array, key_b is a hash.Here is the output:
I debug code and got some clues:
key_a[]=1&key_b[1]=2
is covert tokey_a=1&key_b[1]=2
because of the logic here.key_a[]=1
is not removed as in expected interactionkey_a=1
, which causes the inconsistency between expected interaction and actual interaction.I'm wondering if it's a bug.