Skip to content
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

feat(cts): generate tests for helpers #2798

Merged
merged 27 commits into from
Jun 17, 2024
Merged

feat(cts): generate tests for helpers #2798

merged 27 commits into from
Jun 17, 2024

Conversation

millotp
Copy link
Collaborator

@millotp millotp commented Feb 28, 2024

🧭 What and Why

DI-2464

Use the helper spec to generate tests, starting with the simplest: generateSecuredApiKey

@millotp millotp self-assigned this Feb 28, 2024
@algolia-bot
Copy link
Collaborator

algolia-bot commented Feb 28, 2024

✗ The generated branch has been deleted.

If the PR has been merged, you can check the generated code on the main branch.
You can still access the code generated on main via this commit.

@millotp millotp force-pushed the feat/helper-tests branch 2 times, most recently from 8a51cc3 to 04b4cd7 Compare February 28, 2024 11:00
@millotp millotp changed the base branch from main to feat/go-api-key February 28, 2024 11:01
"object": "$client",
"path": "generateSecuredApiKey",
"parameters": {
"parentAPIKey": "2640659426d5107b6e47d75db9cbaef8",
Copy link
Collaborator Author

@millotp millotp Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no worries this is our search api key, this means the generated key is usable for e2e

Base automatically changed from feat/go-api-key to main February 28, 2024 12:50
@damcou
Copy link
Contributor

damcou commented Feb 28, 2024

I was about to start adding those tests for PHP by hand, is it still useful or should I wait for this PR to be merged ?

@millotp millotp force-pushed the feat/helper-tests branch 2 times, most recently from 0ed2041 to 6f93939 Compare February 29, 2024 15:12
@millotp millotp force-pushed the feat/helper-tests branch from 2207ebe to ec3f8c8 Compare June 11, 2024 13:20
@millotp millotp force-pushed the feat/helper-tests branch from ec3f8c8 to 423e43b Compare June 11, 2024 13:22
@millotp millotp marked this pull request as ready for review June 14, 2024 08:19
@millotp millotp requested a review from a team as a code owner June 14, 2024 08:19
@millotp millotp requested review from damcou and shortcuts June 14, 2024 08:19
Copy link

github-actions bot commented Jun 14, 2024

@github-actions github-actions bot temporarily deployed to pull request June 14, 2024 08:22 Inactive
@algolia algolia deleted a comment from netlify bot Jun 14, 2024
Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks awesome

Comment on lines +51 to +52
Object.prototype.toString.call(parameters[key]) === '[object Array]'
? parameters[key].join(',')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this will break something

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it did break something, it wasn't working before with generateSecuredApiKey, but you agree with me that never ever do we have a query param that looks like a serialezed object right ? we only allow primitives and array to stringified

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup but IIRC this implem was exactly the same as the legacy client but since I never found the reason why it had an object case :/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay but we don't have any tests that expect that, and we don't have the same behavior in other languages, this was an outlier

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can revert this if you want, but I think this is more correct

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think so but since it worked like that for years I think there's an edge case we are not aware of :/ we can leave it and see if there's complains

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted in b9ff92c

Copy link
Collaborator Author

@millotp millotp Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah bah it breaks the test because now it adds brackets to stringified array, thats why I had to put the .join(',')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly wonder how it could've been wrong for 4 years in the current JS client, maybe the engine supports this format?

Your initial solution is indeed correct to me, we can go with it and if user complain we fix it (we can also for example try it on the Crawler migration PoC too)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, the PR should be fine then

if isinstance(value, dict):
return dumps(value)
elif isinstance(value, list):
if isinstance(value, list):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does list validates dict? that's why you changed the order?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing as for js, we never want to stringify a dict

templates/go/api.mustache Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to pull request June 14, 2024 10:07 Inactive
@millotp millotp requested a review from shortcuts June 14, 2024 10:21
@github-actions github-actions bot temporarily deployed to pull request June 14, 2024 12:19 Inactive
shortcuts
shortcuts previously approved these changes Jun 17, 2024
Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤞🏻 🍀

@millotp millotp enabled auto-merge (squash) June 17, 2024 13:18
@github-actions github-actions bot temporarily deployed to pull request June 17, 2024 14:21 Inactive
@millotp millotp requested a review from shortcuts June 17, 2024 15:29
Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐍

@millotp millotp merged commit d7e2075 into main Jun 17, 2024
21 checks passed
@millotp millotp deleted the feat/helper-tests branch June 17, 2024 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants