Skip to content

Commit f76f2f9

Browse files
committed
put the context as first param
1 parent 0c68622 commit f76f2f9

File tree

7 files changed

+54
-52
lines changed

7 files changed

+54
-52
lines changed

templates/go/api.mustache

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828

2929
type config struct {
3030
// -- Request options for API calls
31-
context context.Context
3231
queryParams url.Values
3332
headerParams map[string]string
3433
timeouts transport.RequestConfiguration
@@ -75,12 +74,6 @@ func (r requestOption) apply(c *config) {
7574
r(c)
7675
}
7776

78-
func WithContext(ctx context.Context) requestOption {
79-
return requestOption(func(c *config) {
80-
c.context = ctx
81-
})
82-
}
83-
8477
func WithHeaderParam(key string, value any) requestOption {
8578
return requestOption(func(c *config) {
8679
c.headerParams[key] = utils.ParameterToString(value)
@@ -355,17 +348,17 @@ func (o *{{operationId}}Options) With{{#lambda.titlecase}}{{baseName}}{{/lambda.
355348
{{#optionalParams}}
356349
// - {{paramName}} {{#description}}- {{{.}}}{{/description}} (in optionalParams)
357350
{{/optionalParams}}
358-
// - opts - Optional parameters for the API call (e.g. WithContext, WithHeaderParam...)
351+
// - opts - Optional parameters for the API call (e.g. WithHeaderParam, WithReadTimeout...)
359352
{{#isDeprecated}}
360353
//
361354
// Deprecated: {{operationId}} is deprecated
362355
{{/isDeprecated}}
363-
func (c *APIClient) {{nickname}}({{#requiredParams}}{{paramName}} {{#required}}{{#isModel}}*{{/isModel}}{{/required}}{{^required}}{{^isMap}}*{{/isMap}}{{/required}}{{{dataType}}}, {{/requiredParams}}{{#hasOptionalParams}}optionalParams *{{operationId}}Options, {{/hasOptionalParams}}opts ...RequestOption) ({{#returnType}}{{^isArray}}{{^returnTypeIsPrimitive}}*{{/returnTypeIsPrimitive}}{{/isArray}}{{{.}}}, {{/returnType}}error) {
356+
func (c *APIClient) {{nickname}}(ctx context.Context, {{#requiredParams}}{{paramName}} {{#required}}{{#isModel}}*{{/isModel}}{{/required}}{{^required}}{{^isMap}}*{{/isMap}}{{/required}}{{{dataType}}}, {{/requiredParams}}{{#hasOptionalParams}}optionalParams *{{operationId}}Options, {{/hasOptionalParams}}opts ...RequestOption) ({{#returnType}}{{^isArray}}{{^returnTypeIsPrimitive}}*{{/returnTypeIsPrimitive}}{{/isArray}}{{{.}}}, {{/returnType}}error) {
364357
{{#returnType}}
365358
var returnValue {{^isArray}}{{^returnTypeIsPrimitive}}*{{/returnTypeIsPrimitive}}{{/isArray}}{{{.}}}
366359
{{/returnType}}
367360

368-
res, resBody, err := c.{{nickname}}WithHTTPInfo({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#hasOptionalParams}}optionalParams, {{/hasOptionalParams}}opts...)
361+
res, resBody, err := c.{{nickname}}WithHTTPInfo(ctx, {{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#hasOptionalParams}}optionalParams, {{/hasOptionalParams}}opts...)
369362
if err != nil {
370363
return {{#returnType}}returnValue, {{/returnType}}err
371364
}
@@ -406,12 +399,12 @@ func (c *APIClient) {{nickname}}({{#requiredParams}}{{paramName}} {{#required}}{
406399
{{#optionalParams}}
407400
// - {{paramName}} {{#description}}- {{{.}}}{{/description}} (in optionalParams)
408401
{{/optionalParams}}
409-
// - opts - Optional parameters for the API call (e.g. WithContext, WithHeaderParam...)
402+
// - opts - Optional parameters for the API call (e.g. WithHeaderParam, WithReadTimeout...)
410403
{{#isDeprecated}}
411404
//
412405
// Deprecated: {{operationId}} is deprecated
413406
{{/isDeprecated}}
414-
func (c *APIClient) {{nickname}}WithHTTPInfo({{#requiredParams}}{{paramName}} {{#required}}{{#isModel}}*{{/isModel}}{{/required}}{{^required}}{{^isMap}}*{{/isMap}}{{/required}}{{{dataType}}}, {{/requiredParams}}{{#hasOptionalParams}}optionalParams *{{operationId}}Options, {{/hasOptionalParams}}opts ...RequestOption) (*http.Response, []byte, error) {
407+
func (c *APIClient) {{nickname}}WithHTTPInfo(ctx context.Context, {{#requiredParams}}{{paramName}} {{#required}}{{#isModel}}*{{/isModel}}{{/required}}{{^required}}{{^isMap}}*{{/isMap}}{{/required}}{{{dataType}}}, {{/requiredParams}}{{#hasOptionalParams}}optionalParams *{{operationId}}Options, {{/hasOptionalParams}}opts ...RequestOption) (*http.Response, []byte, error) {
415408
{{#vendorExtensions}}
416409
requestPath := "{{{path}}}"{{#pathParams}}
417410
requestPath = strings.ReplaceAll(requestPath, {{=<% %>=}}"{<%baseName%>}"<%={{ }}=%>, {{#x-is-custom-request}}utils.ParameterToString({{paramName}}){{/x-is-custom-request}}{{^x-is-custom-request}}url.PathEscape(utils.ParameterToString({{paramName}})){{/x-is-custom-request}}){{/pathParams}}
@@ -436,7 +429,6 @@ func (c *APIClient) {{nickname}}WithHTTPInfo({{#requiredParams}}{{paramName}} {{
436429
{{/allParams}}
437430

438431
conf := config{
439-
context: context.Background(),
440432
queryParams: url.Values{},
441433
headerParams: map[string]string{},
442434
{{#vendorExtensions.x-timeouts}}
@@ -533,7 +525,7 @@ func (c *APIClient) {{nickname}}WithHTTPInfo({{#requiredParams}}{{paramName}} {{
533525
{{/required}}
534526
{{/vendorExtensions.x-flat-body}}
535527
{{/bodyParams}}
536-
req, err := c.prepareRequest(conf.context, requestPath, http.Method{{httpMethod}}, {{^bodyParams}}nil{{/bodyParams}}{{#bodyParams}}postBody{{/bodyParams}}, conf.headerParams, conf.queryParams)
528+
req, err := c.prepareRequest(ctx, requestPath, http.Method{{httpMethod}}, {{^bodyParams}}nil{{/bodyParams}}{{#bodyParams}}postBody{{/bodyParams}}, conf.headerParams, conf.queryParams)
537529
if err != nil {
538530
return nil, nil, err
539531
}

templates/go/search_helpers.mustache

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ func CreateIterable[T any](execute func(*T, error) (*T, error), validate func(*T
4343

4444
// SearchForHits calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
4545
// Disclaimer: We don't assert that the parameters you pass to this method only contains `hits` requests to prevent impacting search performances, this helper is purely for typing purposes.
46-
func (c *APIClient) SearchForHits(requests []SearchQuery, strategy *SearchStrategy, opts ...RequestOption) ([]SearchResponse, error) {
47-
res, err := c.Search(requests, strategy, opts...)
46+
func (c *APIClient) SearchForHits(ctx context.Context, requests []SearchQuery, strategy *SearchStrategy, opts ...RequestOption) ([]SearchResponse, error) {
47+
res, err := c.Search(ctx, requests, strategy, opts...)
4848
if err != nil {
4949
return nil, err
5050
}
@@ -62,8 +62,8 @@ func (c *APIClient) SearchForHits(requests []SearchQuery, strategy *SearchStrate
6262

6363
// SearchForFacets calls the `search` method but with certainty that we will only request Algolia facets and not records (hits).
6464
// Disclaimer: We don't assert that the parameters you pass to this method only contains `facets` requests to prevent impacting search performances, this helper is purely for typing purposes.
65-
func (c *APIClient) SearchForFacets(requests []SearchQuery, strategy *SearchStrategy, opts ...RequestOption) ([]SearchForFacetValuesResponse, error) {
66-
res, err := c.Search(requests, strategy, opts...)
65+
func (c *APIClient) SearchForFacets(ctx context.Context,requests []SearchQuery, strategy *SearchStrategy, opts ...RequestOption) ([]SearchForFacetValuesResponse, error) {
66+
res, err := c.Search(ctx, requests, strategy, opts...)
6767
if err != nil {
6868
return nil, err
6969
}
@@ -83,6 +83,7 @@ func (c *APIClient) SearchForFacets(requests []SearchQuery, strategy *SearchStra
8383
// It returns the task response if the operation was successful.
8484
// It returns an error if the operation failed.
8585
func (c *APIClient) WaitForTask(
86+
ctx context.Context,
8687
indexName string,
8788
taskID int64,
8889
opts ...IterableOption,
@@ -94,7 +95,7 @@ func (c *APIClient) WaitForTask(
9495

9596
return CreateIterable( //nolint:wrapcheck
9697
func(*GetTaskResponse, error) (*GetTaskResponse, error) {
97-
return c.GetTask(indexName, taskID, toRequestOptions(opts)...)
98+
return c.GetTask(ctx, indexName, taskID, toRequestOptions(opts)...)
9899
},
99100
func(response *GetTaskResponse, err error) (bool, error) {
100101
if err != nil || response == nil {
@@ -111,6 +112,7 @@ func (c *APIClient) WaitForTask(
111112
// It returns the task response if the operation was successful.
112113
// It returns an error if the operation failed.
113114
func (c *APIClient) WaitForAppTask(
115+
ctx context.Context,
114116
taskID int64,
115117
opts ...IterableOption,
116118
) (*GetTaskResponse, error) {
@@ -121,7 +123,7 @@ func (c *APIClient) WaitForAppTask(
121123

122124
return CreateIterable( //nolint:wrapcheck
123125
func(*GetTaskResponse, error) (*GetTaskResponse, error) {
124-
return c.GetAppTask(taskID, toRequestOptions(opts)...)
126+
return c.GetAppTask(ctx, taskID, toRequestOptions(opts)...)
125127
},
126128
func(response *GetTaskResponse, err error) (bool, error) {
127129
if err != nil || response == nil {
@@ -164,6 +166,7 @@ func slicesEqualUnordered[T cmp.Ordered](a []T, b []T) bool {
164166
// If the operation is "update", the apiKey parameter must be set.
165167
// If the operation is "delete" or "add", the apiKey parameter is not used.
166168
func (c *APIClient) WaitForApiKey(
169+
ctx context.Context,
167170
key string,
168171
operation ApiKeyOperation,
169172
opts ...WaitForApiKeyOption,
@@ -247,7 +250,7 @@ func (c *APIClient) WaitForApiKey(
247250

248251
return CreateIterable( //nolint:wrapcheck
249252
func(*GetApiKeyResponse, error) (*GetApiKeyResponse, error) {
250-
return c.GetApiKey(key, toRequestOptions(opts)...)
253+
return c.GetApiKey(ctx, key, toRequestOptions(opts)...)
251254
},
252255
validateFunc,
253256
waitForApiKeyToIterableOptions(opts)...,
@@ -257,6 +260,7 @@ func (c *APIClient) WaitForApiKey(
257260
// BrowseObjects allows to aggregate all the hits returned by the API calls.
258261
// Use the `WithAggregator` option to collect all the responses.
259262
func (c *APIClient) BrowseObjects(
263+
ctx context.Context,
260264
indexName string,
261265
browseParams BrowseParamsObject,
262266
opts ...IterableOption,
@@ -272,7 +276,7 @@ func (c *APIClient) BrowseObjects(
272276
}
273277

274278
return c.Browse(
275-
indexName, BrowseParamsObjectAsBrowseParams(&browseParams),
279+
ctx, indexName, BrowseParamsObjectAsBrowseParams(&browseParams),
276280
toRequestOptions(opts)...,
277281
)
278282
},
@@ -288,6 +292,7 @@ func (c *APIClient) BrowseObjects(
288292
// BrowseRules allows to aggregate all the rules returned by the API calls.
289293
// Use the `WithAggregator` option to collect all the responses.
290294
func (c *APIClient) BrowseRules(
295+
ctx context.Context,
291296
indexName string,
292297
optionalParams *SearchRulesOptions,
293298
opts ...IterableOption,
@@ -312,7 +317,7 @@ func (c *APIClient) BrowseRules(
312317
optionalParams.Page = utils.ToPtr(int32(0))
313318
}
314319

315-
return c.SearchRules(indexName, optionalParams, toRequestOptions(opts)...)
320+
return c.SearchRules(ctx, indexName, optionalParams, toRequestOptions(opts)...)
316321
},
317322
func(response *SearchRulesResponse, err error) (bool, error) {
318323
return err != nil || (response != nil && len(response.Hits) < int(hitsPerPage)), err
@@ -326,6 +331,7 @@ func (c *APIClient) BrowseRules(
326331
// BrowseSynonyms allows to aggregate all the synonyms returned by the API calls.
327332
// Use the `WithAggregator` option to collect all the responses.
328333
func (c *APIClient) BrowseSynonyms(
334+
ctx context.Context,
329335
indexName string,
330336
optionalParams *SearchSynonymsOptions,
331337
opts ...IterableOption,
@@ -350,7 +356,7 @@ func (c *APIClient) BrowseSynonyms(
350356
optionalParams.Page = utils.ToPtr(*optionalParams.Page + 1)
351357
}()
352358

353-
return c.SearchSynonyms(indexName, optionalParams, toRequestOptions(opts)...)
359+
return c.SearchSynonyms(ctx, indexName, optionalParams, toRequestOptions(opts)...)
354360
},
355361
func(response *SearchSynonymsResponse, err error) (bool, error) {
356362
return err != nil || (response != nil && len(response.Hits) < int(hitsPerPage)), err
@@ -454,23 +460,23 @@ func (c *APIClient) GetSecuredApiKeyRemainingValidity(securedApiKey string) (tim
454460
}
455461

456462
// Helper: Saves the given array of objects in the given index. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
457-
func (c *APIClient) SaveObjects(indexName string, objects []map[string]any, opts ...ChunkedBatchOption) ([]BatchResponse, error) {
458-
return c.ChunkedBatch(indexName, objects, ACTION_ADD_OBJECT, opts...)
463+
func (c *APIClient) SaveObjects(ctx context.Context, indexName string, objects []map[string]any, opts ...ChunkedBatchOption) ([]BatchResponse, error) {
464+
return c.ChunkedBatch(ctx, indexName, objects, ACTION_ADD_OBJECT, opts...)
459465
}
460466

461467
// Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
462-
func (c *APIClient) DeleteObjects(indexName string, objectIDs []string, opts ...ChunkedBatchOption) ([]BatchResponse, error) {
468+
func (c *APIClient) DeleteObjects(ctx context.Context, indexName string, objectIDs []string, opts ...ChunkedBatchOption) ([]BatchResponse, error) {
463469
objects := make([]map[string]any, 0, len(objectIDs))
464470
465471
for _, id := range objectIDs {
466472
objects = append(objects, map[string]any{"objectID":id})
467473
}
468474

469-
return c.ChunkedBatch(indexName, objects, ACTION_DELETE_OBJECT, opts...)
475+
return c.ChunkedBatch(ctx, indexName, objects, ACTION_DELETE_OBJECT, opts...)
470476
}
471477

472478
// Helper: Replaces object content of all the given objects according to their respective `objectID` field. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
473-
func (c *APIClient) PartialUpdateObjects(indexName string, objects []map[string]any, opts ...PartialUpdateObjectsOption) ([]BatchResponse, error) {
479+
func (c *APIClient) PartialUpdateObjects(ctx context.Context, indexName string, objects []map[string]any, opts ...PartialUpdateObjectsOption) ([]BatchResponse, error) {
474480
conf := config{
475481
headerParams: map[string]string{},
476482
createIfNotExists: true,
@@ -488,11 +494,11 @@ func (c *APIClient) PartialUpdateObjects(indexName string, objects []map[string]
488494
action = ACTION_PARTIAL_UPDATE_OBJECT_NO_CREATE
489495
}
490496

491-
return c.ChunkedBatch(indexName, objects, action, partialUpdateObjectsToChunkedBatchOptions(opts)...)
497+
return c.ChunkedBatch(ctx, indexName, objects, action, partialUpdateObjectsToChunkedBatchOptions(opts)...)
492498
}
493499

494500
// ChunkedBatch chunks the given `objects` list in subset of 1000 elements max in order to make it fit in `batch` requests.
495-
func (c *APIClient) ChunkedBatch(indexName string, objects []map[string]any, action Action, opts ...ChunkedBatchOption) ([]BatchResponse, error) {
501+
func (c *APIClient) ChunkedBatch(ctx context.Context, indexName string, objects []map[string]any, action Action, opts ...ChunkedBatchOption) ([]BatchResponse, error) {
496502
conf := config{
497503
headerParams: map[string]string{},
498504
waitForTasks: false,
@@ -510,7 +516,7 @@ func (c *APIClient) ChunkedBatch(indexName string, objects []map[string]any, act
510516
requests = append(requests, *NewBatchRequest(action, obj))
511517
512518
if len(requests) == conf.batchSize || i == len(objects)-1 {
513-
resp, err := c.Batch(indexName, requests, toRequestOptions(opts)...)
519+
resp, err := c.Batch(ctx, indexName, requests, toRequestOptions(opts)...)
514520
if err != nil {
515521
return nil, err
516522
}
@@ -522,7 +528,7 @@ func (c *APIClient) ChunkedBatch(indexName string, objects []map[string]any, act
522528

523529
if conf.waitForTasks {
524530
for _, resp := range responses {
525-
_, err := c.WaitForTask(indexName, resp.TaskID, toIterableOptions(opts)...)
531+
_, err := c.WaitForTask(ctx, indexName, resp.TaskID, toIterableOptions(opts)...)
526532
if err != nil {
527533
return nil, err
528534
}
@@ -620,7 +626,7 @@ func (c *APIClient) ReplaceAllObjectsWithTransformation(indexName string, object
620626

621627
// ReplaceAllObjects replaces all objects (records) in the given `indexName` with the given `objects`. A temporary index is created during this process in order to backup your data.
622628
// See https://api-clients-automation.netlify.app/docs/add-new-api-client#5-helpers for implementation details.
623-
func (c *APIClient) ReplaceAllObjects(indexName string, objects []map[string]any, opts ...ReplaceAllObjectsOption) (*ReplaceAllObjectsResponse, error) {
629+
func (c *APIClient) ReplaceAllObjects(ctx context.Context, indexName string, objects []map[string]any, opts ...ReplaceAllObjectsOption) (*ReplaceAllObjectsResponse, error) {
624630
tmpIndexName := fmt.Sprintf("%s_tmp_%d", indexName, time.Now().UnixNano())
625631
626632
conf := config{
@@ -634,49 +640,49 @@ func (c *APIClient) ReplaceAllObjects(indexName string, objects []map[string]any
634640

635641
opts = append(opts, WithWaitForTasks(true))
636642

637-
copyResp, err := c.OperationIndex(indexName, OPERATION_TYPE_COPY, tmpIndexName, &conf.scopes, toRequestOptions(opts)...)
643+
copyResp, err := c.OperationIndex(ctx, indexName, OPERATION_TYPE_COPY, tmpIndexName, &conf.scopes, toRequestOptions(opts)...)
638644
if err != nil {
639645
return nil, err
640646
}
641647

642-
batchResp, err := c.ChunkedBatch(tmpIndexName, objects, ACTION_ADD_OBJECT, replaceAllObjectsToChunkBatchOptions(opts)...)
648+
batchResp, err := c.ChunkedBatch(ctx, tmpIndexName, objects, ACTION_ADD_OBJECT, replaceAllObjectsToChunkBactchOptions(opts)...)
643649
if err != nil {
644-
_, _ = c.DeleteIndex(tmpIndexName)
650+
_, _ = c.DeleteIndex(ctx, tmpIndexName)
645651
646652
return nil, err
647653
}
648654

649-
_, err = c.WaitForTask(tmpIndexName, copyResp.TaskID, replaceAllObjectsToIterableOptions(opts)...)
655+
_, err = c.WaitForTask(ctx, tmpIndexName, copyResp.TaskID, replaceAllObjectsToIterableOptions(opts)...)
650656
if err != nil {
651-
_, _ = c.DeleteIndex(tmpIndexName)
657+
_, _ = c.DeleteIndex(ctx, tmpIndexName)
652658
653659
return nil, err
654660
}
655661

656-
copyResp, err = c.OperationIndex(indexName, OPERATION_TYPE_COPY, tmpIndexName, &conf.scopes, toRequestOptions(opts)...)
662+
copyResp, err = c.OperationIndex(ctx, indexName, OPERATION_TYPE_COPY, tmpIndexName, &conf.scopes, toRequestOptions(opts)...)
657663
if err != nil {
658-
_, _ = c.DeleteIndex(tmpIndexName)
664+
_, _ = c.DeleteIndex(ctx, tmpIndexName)
659665
660666
return nil, err
661667
}
662668

663-
_, err = c.WaitForTask(tmpIndexName, copyResp.TaskID, replaceAllObjectsToIterableOptions(opts)...)
669+
_, err = c.WaitForTask(ctx, tmpIndexName, copyResp.TaskID, replaceAllObjectsToIterableOptions(opts)...)
664670
if err != nil {
665-
_, _ = c.DeleteIndex(tmpIndexName)
671+
_, _ = c.DeleteIndex(ctx, tmpIndexName)
666672
667673
return nil, err
668674
}
669675

670-
moveResp, err := c.OperationIndex(tmpIndexName, OPERATION_TYPE_MOVE, indexName, nil, toRequestOptions(opts)...)
676+
moveResp, err := c.OperationIndex(ctx, tmpIndexName, OPERATION_TYPE_MOVE, indexName, nil, toRequestOptions(opts)...)
671677
if err != nil {
672-
_, _ = c.DeleteIndex(tmpIndexName)
678+
_, _ = c.DeleteIndex(ctx, tmpIndexName)
673679
674680
return nil, err
675681
}
676682

677-
_, err = c.WaitForTask(tmpIndexName, moveResp.TaskID, replaceAllObjectsToIterableOptions(opts)...)
683+
_, err = c.WaitForTask(ctx, tmpIndexName, moveResp.TaskID, replaceAllObjectsToIterableOptions(opts)...)
678684
if err != nil {
679-
_, _ = c.DeleteIndex(tmpIndexName)
685+
_, _ = c.DeleteIndex(ctx, tmpIndexName)
680686
681687
return nil, err
682688
}
@@ -691,8 +697,8 @@ func (c *APIClient) ReplaceAllObjects(indexName string, objects []map[string]any
691697
// Exists returns whether an initialized index exists or not, along with a nil
692698
// error. When encountering a network error, a non-nil error is returned along
693699
// with false.
694-
func (c *APIClient) IndexExists(indexName string) (bool, error) {
695-
_, err := c.GetSettings(indexName)
700+
func (c *APIClient) IndexExists(ctx context.Context, indexName string) (bool, error) {
701+
_, err := c.GetSettings(ctx, indexName)
696702
if err == nil {
697703
return true, nil
698704
}

templates/go/tests/client/benchmark.mustache

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ package benchmark
44

55
import (
66
"testing"
7-
7+
"regexp"
8+
"context"
89

910
"github.com/stretchr/testify/require"
1011

templates/go/tests/client/client.mustache

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import (
66
"encoding/json"
77
"net/url"
88
"testing"
9-
"time"
9+
"regexp"
10+
"context"
1011

1112
"github.com/kinbiko/jsonassert"
1213
"github.com/stretchr/testify/require"

templates/go/tests/e2e/e2e.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"os"
88
"testing"
9+
"context"
910

1011
"github.com/stretchr/testify/require"
1112
"github.com/kinbiko/jsonassert"

templates/go/tests/method.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
client.{{#lambda.titlecase}}{{method}}{{/lambda.titlecase}}({{> tests/requiredParams}}{{> tests/optionalWrapper}}{{> tests/nilWrapper}}{{> tests/inlineOptional}}{{> tests/requestOptions}})
1+
client.{{#lambda.titlecase}}{{method}}{{/lambda.titlecase}}({{#isAsyncMethod}}context.Background(), {{/isAsyncMethod}}{{> tests/requiredParams}}{{> tests/optionalWrapper}}{{> tests/nilWrapper}}{{> tests/inlineOptional}}{{> tests/requestOptions}})

templates/go/tests/requests/requests.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"testing"
77
"time"
8+
"context"
89

910
"github.com/kinbiko/jsonassert"
1011
"github.com/stretchr/testify/require"

0 commit comments

Comments
 (0)