Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion config/clients.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@
"snippets": {
"extension": ".go",
"outputFolder": "src"
}
},
"supportedVersions": [
"1.24.10",
"1.25.4",
"1.21.11"
]
},
"java": {
"clients": [
Expand Down
2 changes: 1 addition & 1 deletion config/generation.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const patterns = [
'!clients/algoliasearch-client-go/algolia/debug/*',
'!clients/algoliasearch-client-go/algolia/utils/*',

'!tests/output/go/go.*',
'tests/output/go/go.mod',

// Java
'!clients/algoliasearch-client-java/**',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public void addDataToBundle(Map<String, Object> bundle) throws GeneratorExceptio
bundle.put("clientImport", clientPrefix);
}

@Override
public void addTestsSupportingFiles(List<SupportingFile> supportingFiles) {
supportingFiles.add(new SupportingFile("tests/go.mod.mustache", "tests/output/go", "go.mod"));
}

@Override
public void addSnippetsSupportingFiles(List<SupportingFile> supportingFiles, String output) {
supportingFiles.add(new SupportingFile("snippets/.golangci.mustache", output + "/go/.golangci.yml"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ private String escapeBody(String body) {
}

switch (language) {
case "go": // jsonassert expect % to be formatted, we need to escape them
return body.replace("%", "%%");
case "dart": // Same thing but for $
case "dart": // Escape $ to avoid being used for string interpolation
return body.replace("$", "\\$");
default:
return body;
Expand Down
2 changes: 1 addition & 1 deletion templates/go/snippets/go.mod.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module snippets

go 1.21.11
go {{languageVersion}}

replace github.com/algolia/algoliasearch-client-go/v4 => ../../../clients/algoliasearch-client-go

Expand Down
2 changes: 1 addition & 1 deletion templates/go/tests/e2e/e2e.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func Test{{#lambda.titlecase}}{{clientPrefix}}{{/lambda.titlecase}}E2E_{{#lambda
unionBodyRaw, err := json.Marshal(unionBody)
require.NoError(t, err)

jsonassert.New(t).Assertf(string(unionBodyRaw), expectedBodyRaw)
jsonassert.New(t).Assertf(string(unionBodyRaw), "%s", expectedBodyRaw)
{{/body}}
{{/response}}
})
Expand Down
18 changes: 18 additions & 0 deletions templates/go/tests/go.mod.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module gotests

go {{languageVersion}}

replace github.com/algolia/algoliasearch-client-go/v4 => ../../../clients/algoliasearch-client-go

require (
github.com/algolia/algoliasearch-client-go/v4 v4.0.0
github.com/joho/godotenv v1.5.1
github.com/kinbiko/jsonassert v1.1.0
github.com/stretchr/testify v1.11.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
3 changes: 1 addition & 2 deletions templates/go/tests/requests/requests.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ func Test{{#lambda.titlecase}}{{clientPrefix}}{{/lambda.titlecase}}_{{#lambda.ti
require.Equal(t, "{{{method}}}", echo.Method)

{{#body}}
ja := jsonassert.New(t)
ja.Assertf(*echo.Body, `{{{.}}}`)
jsonassert.New(t).Assertf(*echo.Body, "%s", `{{{.}}}`)
{{/body}}
{{^body}}
{{#assertNullBody}}
Expand Down