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): add custom request tests #331

Merged
merged 12 commits into from
Apr 14, 2022
Merged

Conversation

shortcuts
Copy link
Member

@shortcuts shortcuts commented Apr 5, 2022

🧭 What and Why

🎟 JIRA Ticket:

Changes included:

Follow up of #330

  • Add new common folder for requests common to all clients
  • Add tests for the custom requests for each languages
  • Fix typo in Java tests
  • Fix CTS generator failing silently
  • Convert assertions to ifs as it was not triggered

🧪 Test

CI :D

@shortcuts shortcuts requested a review from a team April 5, 2022 09:02
@shortcuts shortcuts self-assigned this Apr 5, 2022
@shortcuts shortcuts requested review from eunjae-lee and damcou and removed request for a team April 5, 2022 09:02
@netlify
Copy link

netlify bot commented Apr 5, 2022

Deploy Preview for api-clients-automation canceled.

Name Link
🔨 Latest commit 42ed0a5
🔍 Latest deploy log https://app.netlify.com/sites/api-clients-automation/deploys/6257e6701a4a4b00082cb590

@algolia-bot
Copy link
Collaborator

algolia-bot commented Apr 5, 2022

✗ The generated branch has been deleted.

If the PR has been merged, you can check the generated code on the main branch.

@shortcuts
Copy link
Member Author

Putting in draft as it need the gen from #330

@shortcuts shortcuts marked this pull request as draft April 5, 2022 09:16
Base automatically changed from fix/customRequest-queryParams to main April 5, 2022 10:48
@shortcuts shortcuts force-pushed the feat/add-customRequest-tests branch from ce404ed to f36cb98 Compare April 5, 2022 14:29
@shortcuts shortcuts force-pushed the feat/add-customRequest-tests branch from f36cb98 to a56fbab Compare April 12, 2022 13:38
@shortcuts shortcuts marked this pull request as ready for review April 12, 2022 14:18
Copy link
Collaborator

@millotp millotp left a comment

Choose a reason for hiding this comment

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

Looking great !

@@ -170,6 +170,9 @@ public Map<String, Object> postProcessSupportingFileData(
System.out.println(e.getMessage());
System.exit(0);
}

System.out.println(e.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

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

huge fix !

"parameters": {
"query": "parameters"
},
"body": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

DELETE method should not have body, from the http spec:

A payload within a DELETE request message has no defined semantics;
sending a payload body on a DELETE request might cause some existing
implementations to reject the request.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point! It's not the case for the current clients, so I think our API handles it. We can still remove it if we think it shouldn't be the case

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, other DELETE operations we have does not have a request body, so I'll remove it 👍🏼

Copy link
Collaborator

Choose a reason for hiding this comment

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

I know that algolia API can be non-standard sometimes but I hope they don't break the http specification at least

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe we just missed that part in the custom request implementation of the current clients

Copy link
Member Author

Choose a reason for hiding this comment

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

Done here: cf915d5

@@ -50,8 +50,8 @@ class {{client}}Tests {

{{#request.searchParams}}
HashMap<String, String> expectedQuery = JSON.deserialize("{{#lambda.escapequotes}}{{{request.searchParams}}}{{/lambda.escapequotes}}", new TypeToken<HashMap<String, String>>() {}.getType());
List<Pair> acutalQuery = req.getQueryParams();
for (Pair p : acutalQuery) {
List<Pair> actualQuery = req.getQueryParams();
Copy link
Collaborator

Choose a reason for hiding this comment

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

oops I have the same code here, you will merge first unfortunately :(

Copy link
Member Author

Choose a reason for hiding this comment

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

D:

millotp
millotp previously approved these changes Apr 13, 2022
@shortcuts
Copy link
Member Author

no changes in PHP 🤔

@@ -274,6 +274,7 @@ jobs:
hashFiles(
format('{0}/lib/Api/{1}.php', matrix.client.folder, matrix.client.api),
format('{0}/lib/Configuration/{1}.php', matrix.client.folder, matrix.client.config),
format('{0}/lib/Model/{1}/**', matrix.client.folder, matrix.client.capitalizedName),
Copy link
Collaborator

Choose a reason for hiding this comment

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

How is that making a difference ? Those files aren't pushed

Copy link
Member Author

Choose a reason for hiding this comment

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

Yet they are not, but required by the cache, I wonder if it will work

Copy link
Member Author

Choose a reason for hiding this comment

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

An other limitation of the cache :( We will need to add it afterward

@shortcuts shortcuts requested a review from millotp April 13, 2022 08:20
millotp
millotp previously approved these changes Apr 13, 2022
@shortcuts shortcuts enabled auto-merge (squash) April 13, 2022 08:28
@shortcuts shortcuts disabled auto-merge April 14, 2022 08:41
@shortcuts shortcuts enabled auto-merge (squash) April 14, 2022 08:41
@@ -35,7 +35,7 @@ async function removeExistingModel(
clientModel = client;
break;
case 'php':
clientModel = createClientName(client, 'php');
clientModel = createClientName(client, 'php').replace('Api', '');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch ! Instead of using replace can you make a common function to capitalize and have another function to add Api ? This could lead to issues if we have api in the client name

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually this function does the right thing, but returns the API name not the client name, I can update it indeed

Copy link
Member Author

Choose a reason for hiding this comment

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

The two fns are so rarely used that I'm not even sure which one should be the "base" one, I guess this works: 42ed0a5

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