-
Notifications
You must be signed in to change notification settings - Fork 21
feat(cts): add requestOptions tests #501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for api-clients-automation ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✗ The generated branch has been deleted.If the PR has been merged, you can check the generated code on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice ! Hope this will be enough to catch all the bugs :)
.../algoliasearch-client-javascript/packages/client-common/src/transporter/createTransporter.ts
Show resolved
Hide resolved
generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java
Outdated
Show resolved
Hide resolved
2e76ad4
to
fd515f2
Compare
fd515f2
to
55f1ead
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just minor comments, GG !
generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java
Outdated
Show resolved
Hide resolved
generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java
Outdated
Show resolved
Hide resolved
311ea83
to
81c74e9
Compare
@@ -63,39 +63,19 @@ private function normalize($options) | |||
]; | |||
|
|||
foreach ($options as $optionName => $value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After adding boolean tests, I realized PHP formatted booleans array like [true, true, false]
to [1,1,]
, which would have been wrong in our case
I also realized that we were handling query parameters twice (here, and in buildQuery
), so I've moved all the logic there
Could you please confirm it's correct to you? Tests pass correctly but better safe than sorry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine ... But I'm pretty sure at some point I had the issue with the attributesToRetrieve
param not being formatted correctly in the CTS so now I'm quite lost why it's working :D .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's now done directly here in the buildQuery
method, looking at the CTS it's still formatted correctly. Do you have any other stuff in mind we should check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is the only issue of that type, I think we're good.
$args = array_map(function ($value) { | ||
if (is_array($value)) { | ||
return json_encode($value); | ||
// PHP converts `true,false` in arrays to `1,`, so we create strings instead | ||
// to avoid sending wrong values | ||
$values = array_map(function ($v) { | ||
if (is_bool($v)) { | ||
return $v ? 'true' : 'false'; | ||
} | ||
|
||
return $v; | ||
}, $value); | ||
|
||
// We then return the array as a string comma separated | ||
return implode(',', $values); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what was duplicated in the RequestOptionFactory
that I commented above
🧭 What and Why
🎟 JIRA Ticket: https://algolia.atlassian.net/browse/APIC-470
Changes included:
This PR adds tests for the
requestOptions
parameter, available on every methods of every clients:requestOptions
parameter is available at the same level as theparameters
in a CTS filequeryParameters
orheaders
optionI've leveraged the
common
tests added for thecustomRequest
, so we can have tests generated on every clients under the same method.What's next
Docs will be updated in https://algolia.atlassian.net/browse/APIC-484
🧪 Test
CI :D