-
Notifications
You must be signed in to change notification settings - Fork 17
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(go): CTS implementation for go client #1509
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 ! But it looks like the tests are not generated on the CI, I think it's an artifact issue, can you try to tweak .github/actions/restore-artifacts/action.yml
file to include cts ?
@@ -22,6 +22,17 @@ async function runCtsOne(language: string): Promise<void> { | |||
); | |||
break; | |||
} | |||
case 'go': | |||
if (DOCKER) { |
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.
I don't think you need the distinction for docker, /usr/local/go/bin/go
is already in the PATH
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.
Unfortunately, it is in the PATH
but somehow it is not working with js runtime. I can run with just go
from the container but when I used it with the run function it is not working.
I couldn't quite figure out the reason last time. So I already opened a separate ticket to resolve this if possible.
@@ -55,6 +55,9 @@ | |||
] | |||
} | |||
} | |||
}, | |||
"extras": { | |||
"skipForGo": true |
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.
do you have an idea why the payload doesn't work here ? is it because of oneOf ?
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.
Yes mainly because of "oneof". The contents of "oneof"s are very similar for this request. Since I used the json unmarshalling, the expected request body is not matching completely. It is unmarshalling it to a different "oneof" because it is matching with more than one statement.
When I tried to create the request with a constructor it worked without an issue, I couldn't make it work for the tests. I have opened another ticket to improve some of the CTS workflow for development. Maybe that can ease the development so we can take a look at this later on.
@millotp Oh, I tried on local but I haven't noticed the test code does not exist on the generated branch. It is my bad. Let me take a look and update here. Thanks for the heads up. |
@millotp push problem for the generated branch should be resolved. It is ready to be reviewed again. I also do some extra tests for negative and positive CI scenarios to ensure 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.
looks great GG ! Huge PR
} | ||
|
||
{{#blocksRequests}} | ||
func Test{{#lambda.titlecase}}{{clientPrefix}}{{/lambda.titlecase}}_{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}(t *testing.T) { |
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.
I know the execution time is already very fast, but can you add t.Parallel()
here and in the for loop pls ?
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.
since currently, we are using only an echo requester adding t.Parallel()
is bringing flakiness to the tests. Some tests start randomly failing.
We may need to add some complexity to test cases to handle this, I guess we can skip this at this phase.
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 worries the test runs very fast already
|
||
{{#request.body}} | ||
ja := jsonassert.New(t) | ||
ja.Assertf(*echo.body, `{{{request.body}}}`) |
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.
is it possible to assert the query params too ? if they are returned from the echo requester
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.
Thanks for noticing. While adding query param and header assertions I noticed a few problems regarding the custom requests. They are also fixed with 402d69a and all ready to be reviewed.
Nice work! and as you mentioned, I am for revisiting the CTS specs for easier tests generation! Well done! 🚀 |
…plementation # Conflicts: # generators/src/main/java/com/algolia/codegen/cts/manager/CTSManagerFactory.java # scripts/cts/runCts.ts
{{#request.queryParameters}} | ||
queryParams := map[string]string{} | ||
require.NoError(t, json.Unmarshal([]byte(`{{{.}}}`), &queryParams)) | ||
for k, v := range queryParams { |
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.
I don't remember what we do in other languages, but it might be worth to do a strict comparaison here, and check that the number of query params is the same in queryParams
and in echo.query
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.
oh, I miss this before merging. But I noted this to check out.
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.
looks amazing ! somehow kotlin shows up in the generation this time @aallam 🤔
🧭 What and Why
🎟 JIRA Ticket: https://algolia.atlassian.net/browse/APIC-661
The CTS suite for go client implemented.
Changes included:
extras
field added to test json specs.skipForGo
prop. It was needed for three specific test cases. The client was working okay but the test unmarshalling was not working properly because of the payload. No need to block this improvement for this.extras
can be also used for some other cases in the future because the only request may not be enough for all the language generations.UnmarshalJSON
implemented for request struct to handle json parsing for the direct request.🧪 Test
The test should run with CI.