Skip to content

Commit c61eb56

Browse files
committed
put the context as first param
1 parent 78ce426 commit c61eb56

File tree

7 files changed

+52
-50
lines changed

7 files changed

+52
-50
lines changed

templates/go/api.mustache

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

2828
type config struct {
2929
// -- Request options for API calls
30-
context context.Context
3130
queryParams url.Values
3231
headerParams map[string]string
3332
timeouts transport.RequestConfiguration
@@ -63,12 +62,6 @@ func (r requestOption) apply(c *config) {
6362
r(c)
6463
}
6564

66-
func WithContext(ctx context.Context) requestOption {
67-
return requestOption(func(c *config) {
68-
c.context = ctx
69-
})
70-
}
71-
7265
func WithHeaderParam(key string, value any) requestOption {
7366
return requestOption(func(c *config) {
7467
c.headerParams[key] = utils.ParameterToString(value)
@@ -403,17 +396,17 @@ func (o *{{operationId}}Options) With{{#lambda.titlecase}}{{baseName}}{{/lambda.
403396
{{#optionalParams}}
404397
// - {{paramName}} {{#description}}- {{{.}}}{{/description}} (in optionalParams)
405398
{{/optionalParams}}
406-
// - opts - Optional parameters for the API call (e.g. WithContext, WithHeaderParam...)
399+
// - opts - Optional parameters for the API call (e.g. WithHeaderParam, WithReadTimeout...)
407400
{{#isDeprecated}}
408401
//
409402
// Deprecated: {{operationId}} is deprecated
410403
{{/isDeprecated}}
411-
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) {
404+
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) {
412405
{{#returnType}}
413406
var returnValue {{^isArray}}{{^returnTypeIsPrimitive}}*{{/returnTypeIsPrimitive}}{{/isArray}}{{{.}}}
414407
{{/returnType}}
415408

416-
res, resBody, err := c.{{nickname}}WithHTTPInfo({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#hasOptionalParams}}optionalParams, {{/hasOptionalParams}}opts...)
409+
res, resBody, err := c.{{nickname}}WithHTTPInfo(ctx, {{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#hasOptionalParams}}optionalParams, {{/hasOptionalParams}}opts...)
417410
if err != nil {
418411
return {{#returnType}}returnValue, {{/returnType}}err
419412
}
@@ -454,12 +447,12 @@ func (c *APIClient) {{nickname}}({{#requiredParams}}{{paramName}} {{#required}}{
454447
{{#optionalParams}}
455448
// - {{paramName}} {{#description}}- {{{.}}}{{/description}} (in optionalParams)
456449
{{/optionalParams}}
457-
// - opts - Optional parameters for the API call (e.g. WithContext, WithHeaderParam...)
450+
// - opts - Optional parameters for the API call (e.g. WithHeaderParam, WithReadTimeout...)
458451
{{#isDeprecated}}
459452
//
460453
// Deprecated: {{operationId}} is deprecated
461454
{{/isDeprecated}}
462-
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) {
455+
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) {
463456
{{#vendorExtensions}}
464457
requestPath := "{{{path}}}"{{#pathParams}}
465458
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}}
@@ -484,7 +477,6 @@ func (c *APIClient) {{nickname}}WithHTTPInfo({{#requiredParams}}{{paramName}} {{
484477
{{/allParams}}
485478

486479
conf := config{
487-
context: context.Background(),
488480
queryParams: url.Values{},
489481
headerParams: map[string]string{},
490482
{{#vendorExtensions.x-timeouts}}
@@ -581,7 +573,7 @@ func (c *APIClient) {{nickname}}WithHTTPInfo({{#requiredParams}}{{paramName}} {{
581573
{{/required}}
582574
{{/vendorExtensions.x-flat-body}}
583575
{{/bodyParams}}
584-
req, err := c.prepareRequest(conf.context, requestPath, http.Method{{httpMethod}}, {{^bodyParams}}nil{{/bodyParams}}{{#bodyParams}}postBody{{/bodyParams}}, conf.headerParams, conf.queryParams)
576+
req, err := c.prepareRequest(ctx, requestPath, http.Method{{httpMethod}}, {{^bodyParams}}nil{{/bodyParams}}{{#bodyParams}}postBody{{/bodyParams}}, conf.headerParams, conf.queryParams)
585577
if err != nil {
586578
return nil, nil, err
587579
}

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
}
@@ -534,7 +540,7 @@ func (c *APIClient) ChunkedBatch(indexName string, objects []map[string]any, act
534540

535541
// 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.
536542
// See https://api-clients-automation.netlify.app/docs/add-new-api-client#5-helpers for implementation details.
537-
func (c *APIClient) ReplaceAllObjects(indexName string, objects []map[string]any, opts ...ReplaceAllObjectsOption) (*ReplaceAllObjectsResponse, error) {
543+
func (c *APIClient) ReplaceAllObjects(ctx context.Context, indexName string, objects []map[string]any, opts ...ReplaceAllObjectsOption) (*ReplaceAllObjectsResponse, error) {
538544
tmpIndexName := fmt.Sprintf("%s_tmp_%d", indexName, time.Now().UnixNano())
539545
540546
conf := config{
@@ -548,49 +554,49 @@ func (c *APIClient) ReplaceAllObjects(indexName string, objects []map[string]any
548554

549555
opts = append(opts, WithWaitForTasks(true))
550556

551-
copyResp, err := c.OperationIndex(indexName, OPERATION_TYPE_COPY, tmpIndexName, &conf.scopes, toRequestOptions(opts)...)
557+
copyResp, err := c.OperationIndex(ctx, indexName, OPERATION_TYPE_COPY, tmpIndexName, &conf.scopes, toRequestOptions(opts)...)
552558
if err != nil {
553559
return nil, err
554560
}
555561

556-
batchResp, err := c.ChunkedBatch(tmpIndexName, objects, ACTION_ADD_OBJECT, replaceAllObjectsToChunkBactchOptions(opts)...)
562+
batchResp, err := c.ChunkedBatch(ctx, tmpIndexName, objects, ACTION_ADD_OBJECT, replaceAllObjectsToChunkBactchOptions(opts)...)
557563
if err != nil {
558-
_, _ = c.DeleteIndex(tmpIndexName)
564+
_, _ = c.DeleteIndex(ctx, tmpIndexName)
559565
560566
return nil, err
561567
}
562568

563-
_, err = c.WaitForTask(tmpIndexName, copyResp.TaskID, replaceAllObjectsToIterableOptions(opts)...)
569+
_, err = c.WaitForTask(ctx, tmpIndexName, copyResp.TaskID, replaceAllObjectsToIterableOptions(opts)...)
564570
if err != nil {
565-
_, _ = c.DeleteIndex(tmpIndexName)
571+
_, _ = c.DeleteIndex(ctx, tmpIndexName)
566572
567573
return nil, err
568574
}
569575

570-
copyResp, err = c.OperationIndex(indexName, OPERATION_TYPE_COPY, tmpIndexName, &conf.scopes, toRequestOptions(opts)...)
576+
copyResp, err = c.OperationIndex(ctx, indexName, OPERATION_TYPE_COPY, tmpIndexName, &conf.scopes, toRequestOptions(opts)...)
571577
if err != nil {
572-
_, _ = c.DeleteIndex(tmpIndexName)
578+
_, _ = c.DeleteIndex(ctx, tmpIndexName)
573579
574580
return nil, err
575581
}
576582

577-
_, err = c.WaitForTask(tmpIndexName, copyResp.TaskID, replaceAllObjectsToIterableOptions(opts)...)
583+
_, err = c.WaitForTask(ctx, tmpIndexName, copyResp.TaskID, replaceAllObjectsToIterableOptions(opts)...)
578584
if err != nil {
579-
_, _ = c.DeleteIndex(tmpIndexName)
585+
_, _ = c.DeleteIndex(ctx, tmpIndexName)
580586
581587
return nil, err
582588
}
583589

584-
moveResp, err := c.OperationIndex(tmpIndexName, OPERATION_TYPE_MOVE, indexName, nil, toRequestOptions(opts)...)
590+
moveResp, err := c.OperationIndex(ctx, tmpIndexName, OPERATION_TYPE_MOVE, indexName, nil, toRequestOptions(opts)...)
585591
if err != nil {
586-
_, _ = c.DeleteIndex(tmpIndexName)
592+
_, _ = c.DeleteIndex(ctx, tmpIndexName)
587593
588594
return nil, err
589595
}
590596

591-
_, err = c.WaitForTask(tmpIndexName, moveResp.TaskID, replaceAllObjectsToIterableOptions(opts)...)
597+
_, err = c.WaitForTask(ctx, tmpIndexName, moveResp.TaskID, replaceAllObjectsToIterableOptions(opts)...)
592598
if err != nil {
593-
_, _ = c.DeleteIndex(tmpIndexName)
599+
_, _ = c.DeleteIndex(ctx, tmpIndexName)
594600
595601
return nil, err
596602
}
@@ -605,8 +611,8 @@ func (c *APIClient) ReplaceAllObjects(indexName string, objects []map[string]any
605611
// Exists returns whether an initialized index exists or not, along with a nil
606612
// error. When encountering a network error, a non-nil error is returned along
607613
// with false.
608-
func (c *APIClient) IndexExists(indexName string) (bool, error) {
609-
_, err := c.GetSettings(indexName)
614+
func (c *APIClient) IndexExists(ctx context.Context, indexName string) (bool, error) {
615+
_, err := c.GetSettings(ctx, indexName)
610616
if err == nil {
611617
return true, nil
612618
}

templates/go/tests/client/benchmark.mustache

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

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

templates/go/tests/client/client.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/url"
88
"testing"
99
"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
@@ -5,6 +5,7 @@ package e2e
55
import (
66
"os"
77
"testing"
8+
"context"
89

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

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)