From 03099c8470611e1aeb06dd0d3425d3f48138c340 Mon Sep 17 00:00:00 2001 From: catalinaperalta Date: Thu, 21 May 2020 17:05:47 -0400 Subject: [PATCH] Final response handler for Pollers and updating tests (#400) * Removing operation response handler and adding custom handler for final response * Updating some lro tests with new design * Adding response handler as method on pollers, adding response handler method on pollingTracker, minor code fixes * Removing unnecessary test code * Improve tests, check payload * Adding special FinalResponse case for HTTPPollers * Fix HTTP pollers final response method and related tests * Removing unused handleresponse for http pollers and fixed PollUntilDone loop * Adding updated lro tests * Updating internal pollUntilDone to be a method on the unexported poller * Improving ResumeWrongPoller test * Removing time.Duration declarations in tests Co-authored-by: Catalina Peralta --- src/generator/operations.ts | 14 +- src/generator/pollers.ts | 113 +- src/transform/transform.ts | 2 +- test/autorest/generated/lrogroup/lroretrys.go | 57 +- test/autorest/generated/lrogroup/lros.go | 293 +-- test/autorest/generated/lrogroup/lrosads.go | 214 +- .../generated/lrogroup/lroscustomheader.go | 32 +- test/autorest/generated/lrogroup/models.go | 2 +- test/autorest/generated/lrogroup/pollers.go | 122 +- .../generated/lrogroup/pollers_helper.go | 7 + test/autorest/lrogroup/lros_test.go | 2071 ++++++++--------- 11 files changed, 1370 insertions(+), 1557 deletions(-) diff --git a/src/generator/operations.ts b/src/generator/operations.ts index dc356a627..60c0804e8 100644 --- a/src/generator/operations.ts +++ b/src/generator/operations.ts @@ -299,13 +299,18 @@ function generateOperation(clientName: string, op: Operation, imports: ImportMan text += `\tif err != nil {\n`; text += `\t\treturn nil, err\n`; text += `\t}\n`; - text += `\tresult.Poller = &${camelCase(op.language.go!.pollerType.name)}{\n`; + text += `\tpoller := &${camelCase(op.language.go!.pollerType.name)}{\n`; text += `\t\t\tpt: pt,\n`; text += `\t\t\tpipeline: client.p,\n`; - text += `\t\t\tresponse: client.${info.protocolNaming.responseMethod},\n`; text += `\t}\n`; - text += `\tresult.PollUntilDone = func(ctx context.Context, frequency time.Duration)(*${op.language.go!.pollerType.responseType}Response, error) {\n`; - text += `\t\treturn ${camelCase(op.language.go!.pollerType.name)}PollUntilDone(ctx, result.Poller, frequency)\n`; + text += '\tresult.Poller = poller\n'; + // http pollers will simply return an *http.Response + if (op.language.go!.pollerType.name === 'HTTPPoller') { + text += `\tresult.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) {\n`; + } else { + text += `\tresult.PollUntilDone = func(ctx context.Context, frequency time.Duration)(*${op.language.go!.pollerType.responseType}Response, error) {\n`; + } + text += `\t\treturn poller.pollUntilDone(ctx, frequency)\n`; text += `\t}\n`; text += `\treturn result, nil\n`; // closing braces @@ -954,7 +959,6 @@ function addResumePollerMethod(op: Operation, clientName: string): string { text += `\treturn &${camelCase(op.language.go!.pollerType.name)}{\n`; text += '\t\tpipeline: client.p,\n'; text += '\t\tpt: pt,\n'; - text += `\t\tresponse: client.${info.protocolNaming.responseMethod},\n`; text += '\t}, nil\n'; text += '}\n'; return text; diff --git a/src/generator/pollers.ts b/src/generator/pollers.ts index fb99526b0..94c569ade 100644 --- a/src/generator/pollers.ts +++ b/src/generator/pollers.ts @@ -34,35 +34,79 @@ export async function generatePollers(session: Session): Promisepoller.op.responses![0]; let unmarshalResponse = 'nil'; if (isSchemaResponse(schemaResponse) && schemaResponse.schema.language.go!.responseType.value != undefined) { - unmarshalResponse = `resp.UnmarshalAsJSON(&result.${schemaResponse.schema.language.go!.responseType.value})`; - } - if (isSchemaResponse(schemaResponse)) { - responseHandler = `${camelCase(schemaResponse.schema.language.go!.name)}HandleResponse`; responseType = schemaResponse.schema.language.go!.responseType.name; + pollUntilDoneResponse = `(*${responseType}, error)`; + pollUntilDoneReturn = 'p.FinalResponse(ctx)'; rawResponse = '.RawResponse'; + unmarshalResponse = `resp.UnmarshalAsJSON(&result.${schemaResponse.schema.language.go!.responseType.value})`; + // for operations that do return a model add a final response method that handles the final get URL scenario + finalResponseDeclaration = `FinalResponse(ctx context.Context) (*${responseType}, error)`; + finalResponse = `FinalResponse(ctx context.Context) (*${responseType}, error) { + if p.pt.finalGetURL() == "" { + // we can end up in this situation if the async operation returns a 200 + // with no polling URLs. in that case return the response which should + // contain the JSON payload (only do this for successful terminal cases). + if lr := p.pt.latestResponse(); lr != nil && p.pt.hasSucceeded() { + result, err := p.handleResponse(lr) + if err != nil { + return nil, err + } + return result, nil + } + return nil, errors.New("missing URL for retrieving result") + } + u, err := url.Parse(p.pt.finalGetURL()) + if err != nil { + return nil, err + } + req := azcore.NewRequest(http.MethodGet, *u) + if err != nil { + return nil, err + } + resp, err := p.pipeline.Do(ctx, req) + if err != nil { + return nil, err + } + return p.handleResponse(resp) + }`; + handleResponse = ` + func (p *${pollerName}) handleResponse(resp *azcore.Response) (*${responseType}, error) { + result := ${responseType}{RawResponse: resp.Response} + if (resp.HasStatusCode(http.StatusNoContent)) { + return &result, nil + } + if !resp.HasStatusCode(pollingCodes[:]...) { + return nil, p.pt.handleError(resp) + } + return &result, ${unmarshalResponse} + } + `; } bodyText += `// ${pollerInterface} provides polling facilities until the operation completes type ${pollerInterface} interface { Done() bool Poll(ctx context.Context) (*http.Response, error) - FinalResponse(ctx context.Context) (*${responseType}, error) + ${finalResponseDeclaration} ResumeToken() (string, error) } -type ${camelCase(schemaResponse.schema.language.go!.name)}HandleResponse func(*azcore.Response) (*${responseType}, error) - type ${pollerName} struct { // the client for making the request pipeline azcore.Pipeline // polling tracker pt pollingTracker - // use the response handler to check for accepted status codes - response ${responseHandler} } // Done returns true if there was an error or polling has reached a terminal state @@ -78,34 +122,7 @@ func (p *${pollerName}) Poll(ctx context.Context) (*http.Response, error) { return nil, p.pt.pollingError() } -func (p *${pollerName}) FinalResponse(ctx context.Context) (*${responseType}, error) { - if p.pt.finalGetURL() == "" { - // we can end up in this situation if the async operation returns a 200 - // with no polling URLs. in that case return the response which should - // contain the JSON payload (only do this for successful terminal cases). - if lr := p.pt.latestResponse(); lr != nil && p.pt.hasSucceeded() { - result, err := p.response(lr) - if err != nil { - return nil, err - } - return result, nil - } - return nil, errors.New("missing URL for retrieving result") - } - u, err := url.Parse(p.pt.finalGetURL()) - if err != nil { - return nil, err - } - req := azcore.NewRequest(http.MethodGet, *u) - if err != nil { - return nil, err - } - resp, err := p.pipeline.Do(ctx, req) - if err != nil { - return nil, err - } - return p.response(resp) -} +func (p *${pollerName}) ${finalResponse} // ResumeToken generates the string token that can be used with the Resume${pollerInterface} method // on the client to create a new poller from the data held in the current poller type @@ -120,21 +137,24 @@ func (p *${pollerName}) ResumeToken() (string, error) { return string(js), nil } -func ${pollerName}PollUntilDone(ctx context.Context, p ${pollerInterface}, frequency time.Duration) (*${responseType}, error) { - for !p.Done() { +func (p *${pollerName}) pollUntilDone(ctx context.Context, frequency time.Duration) ${pollUntilDoneResponse} { + for { resp, err := p.Poll(ctx) if err != nil { return nil, err } + if p.Done() { + break + } if delay := azcore.RetryAfter(resp); delay > 0 { time.Sleep(delay) } else { time.Sleep(frequency) } } - return p.FinalResponse(ctx) + return ${pollUntilDoneReturn} } - +${handleResponse} `; } text += imports.text(); @@ -234,6 +254,9 @@ type pollingTracker interface { // returns the cached HTTP response after a call to pollForStatus(), can be nil latestResponse() *azcore.Response + + // converts an *azcore.Response to an error + handleError(resp *azcore.Response) error } type methodErrorHandler func(resp *azcore.Response) error @@ -491,7 +514,11 @@ type pollingTrackerBase struct { // it's ok if we didn't find a polling header, this will be handled elsewhere return nil } - + + func (pt *pollingTrackerBase) handleError(resp *azcore.Response) error { + return pt.errorHandler(resp) + } + // DELETE type pollingTrackerDelete struct { diff --git a/src/transform/transform.ts b/src/transform/transform.ts index b3e10e4b5..1f7ea5f1b 100644 --- a/src/transform/transform.ts +++ b/src/transform/transform.ts @@ -410,7 +410,7 @@ function createResponseType(codeModel: CodeModel, group: OperationGroup, op: Ope const description = `${name} contains the HTTP response from the call to the service endpoint`; const object = new ObjectSchema(name, description); object.language.go = object.language.default; - const pollUntilDone = newProperty('PollUntilDone', 'PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received', newObject('func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error)', 'TODO')); + const pollUntilDone = newProperty('PollUntilDone', 'PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received', newObject('func(ctx context.Context, frequency time.Duration) (*http.Response, error)', 'TODO')); const getPoller = newProperty('Poller', 'Poller contains an initialized poller', newObject('HTTPPoller', 'TODO')); pollUntilDone.schema.language.go!.lroPointerException = true; getPoller.schema.language.go!.lroPointerException = true; diff --git a/test/autorest/generated/lrogroup/lroretrys.go b/test/autorest/generated/lrogroup/lroretrys.go index 237ed7ef4..596b4dcce 100644 --- a/test/autorest/generated/lrogroup/lroretrys.go +++ b/test/autorest/generated/lrogroup/lroretrys.go @@ -68,13 +68,13 @@ func (client *lroRetrysOperations) BeginDelete202Retry200(ctx context.Context) ( if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.delete202Retry200HandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -87,7 +87,6 @@ func (client *lroRetrysOperations) ResumeDelete202Retry200(token string) (HTTPPo return &httpPoller{ pipeline: client.p, pt: pt, - response: client.delete202Retry200HandleResponse, }, nil } @@ -138,13 +137,13 @@ func (client *lroRetrysOperations) BeginDeleteAsyncRelativeRetrySucceeded(ctx co if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.deleteAsyncRelativeRetrySucceededHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -157,7 +156,6 @@ func (client *lroRetrysOperations) ResumeDeleteAsyncRelativeRetrySucceeded(token return &httpPoller{ pipeline: client.p, pt: pt, - response: client.deleteAsyncRelativeRetrySucceededHandleResponse, }, nil } @@ -208,13 +206,13 @@ func (client *lroRetrysOperations) BeginDeleteProvisioning202Accepted200Succeede if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.deleteProvisioning202Accepted200SucceededHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -227,7 +225,6 @@ func (client *lroRetrysOperations) ResumeDeleteProvisioning202Accepted200Succeed return &productPoller{ pipeline: client.p, pt: pt, - response: client.deleteProvisioning202Accepted200SucceededHandleResponse, }, nil } @@ -279,13 +276,13 @@ func (client *lroRetrysOperations) BeginPost202Retry200(ctx context.Context, lro if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.post202Retry200HandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -298,7 +295,6 @@ func (client *lroRetrysOperations) ResumePost202Retry200(token string) (HTTPPoll return &httpPoller{ pipeline: client.p, pt: pt, - response: client.post202Retry200HandleResponse, }, nil } @@ -352,13 +348,13 @@ func (client *lroRetrysOperations) BeginPostAsyncRelativeRetrySucceeded(ctx cont if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.postAsyncRelativeRetrySucceededHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -371,7 +367,6 @@ func (client *lroRetrysOperations) ResumePostAsyncRelativeRetrySucceeded(token s return &httpPoller{ pipeline: client.p, pt: pt, - response: client.postAsyncRelativeRetrySucceededHandleResponse, }, nil } @@ -425,13 +420,13 @@ func (client *lroRetrysOperations) BeginPut201CreatingSucceeded200(ctx context.C if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.put201CreatingSucceeded200HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -444,7 +439,6 @@ func (client *lroRetrysOperations) ResumePut201CreatingSucceeded200(token string return &productPoller{ pipeline: client.p, pt: pt, - response: client.put201CreatingSucceeded200HandleResponse, }, nil } @@ -499,13 +493,13 @@ func (client *lroRetrysOperations) BeginPutAsyncRelativeRetrySucceeded(ctx conte if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putAsyncRelativeRetrySucceededHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -518,7 +512,6 @@ func (client *lroRetrysOperations) ResumePutAsyncRelativeRetrySucceeded(token st return &productPoller{ pipeline: client.p, pt: pt, - response: client.putAsyncRelativeRetrySucceededHandleResponse, }, nil } diff --git a/test/autorest/generated/lrogroup/lros.go b/test/autorest/generated/lrogroup/lros.go index e8c6836a9..e688c0dd0 100644 --- a/test/autorest/generated/lrogroup/lros.go +++ b/test/autorest/generated/lrogroup/lros.go @@ -196,13 +196,13 @@ func (client *lrOSOperations) BeginDelete202NoRetry204(ctx context.Context) (*Pr if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.delete202NoRetry204HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -215,7 +215,6 @@ func (client *lrOSOperations) ResumeDelete202NoRetry204(token string) (ProductPo return &productPoller{ pipeline: client.p, pt: pt, - response: client.delete202NoRetry204HandleResponse, }, nil } @@ -267,13 +266,13 @@ func (client *lrOSOperations) BeginDelete202Retry200(ctx context.Context) (*Prod if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.delete202Retry200HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -286,7 +285,6 @@ func (client *lrOSOperations) ResumeDelete202Retry200(token string) (ProductPoll return &productPoller{ pipeline: client.p, pt: pt, - response: client.delete202Retry200HandleResponse, }, nil } @@ -338,13 +336,13 @@ func (client *lrOSOperations) BeginDelete204Succeeded(ctx context.Context) (*HTT if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.delete204SucceededHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -357,7 +355,6 @@ func (client *lrOSOperations) ResumeDelete204Succeeded(token string) (HTTPPoller return &httpPoller{ pipeline: client.p, pt: pt, - response: client.delete204SucceededHandleResponse, }, nil } @@ -409,13 +406,13 @@ func (client *lrOSOperations) BeginDeleteAsyncNoHeaderInRetry(ctx context.Contex if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.deleteAsyncNoHeaderInRetryHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -428,7 +425,6 @@ func (client *lrOSOperations) ResumeDeleteAsyncNoHeaderInRetry(token string) (HT return &httpPoller{ pipeline: client.p, pt: pt, - response: client.deleteAsyncNoHeaderInRetryHandleResponse, }, nil } @@ -479,13 +475,13 @@ func (client *lrOSOperations) BeginDeleteAsyncNoRetrySucceeded(ctx context.Conte if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.deleteAsyncNoRetrySucceededHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -498,7 +494,6 @@ func (client *lrOSOperations) ResumeDeleteAsyncNoRetrySucceeded(token string) (H return &httpPoller{ pipeline: client.p, pt: pt, - response: client.deleteAsyncNoRetrySucceededHandleResponse, }, nil } @@ -549,13 +544,13 @@ func (client *lrOSOperations) BeginDeleteAsyncRetryFailed(ctx context.Context) ( if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.deleteAsyncRetryFailedHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -568,7 +563,6 @@ func (client *lrOSOperations) ResumeDeleteAsyncRetryFailed(token string) (HTTPPo return &httpPoller{ pipeline: client.p, pt: pt, - response: client.deleteAsyncRetryFailedHandleResponse, }, nil } @@ -619,13 +613,13 @@ func (client *lrOSOperations) BeginDeleteAsyncRetrySucceeded(ctx context.Context if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.deleteAsyncRetrySucceededHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -638,7 +632,6 @@ func (client *lrOSOperations) ResumeDeleteAsyncRetrySucceeded(token string) (HTT return &httpPoller{ pipeline: client.p, pt: pt, - response: client.deleteAsyncRetrySucceededHandleResponse, }, nil } @@ -689,13 +682,13 @@ func (client *lrOSOperations) BeginDeleteAsyncRetrycanceled(ctx context.Context) if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.deleteAsyncRetrycanceledHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -708,7 +701,6 @@ func (client *lrOSOperations) ResumeDeleteAsyncRetrycanceled(token string) (HTTP return &httpPoller{ pipeline: client.p, pt: pt, - response: client.deleteAsyncRetrycanceledHandleResponse, }, nil } @@ -759,13 +751,13 @@ func (client *lrOSOperations) BeginDeleteNoHeaderInRetry(ctx context.Context) (* if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.deleteNoHeaderInRetryHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -778,7 +770,6 @@ func (client *lrOSOperations) ResumeDeleteNoHeaderInRetry(token string) (HTTPPol return &httpPoller{ pipeline: client.p, pt: pt, - response: client.deleteNoHeaderInRetryHandleResponse, }, nil } @@ -829,13 +820,13 @@ func (client *lrOSOperations) BeginDeleteProvisioning202Accepted200Succeeded(ctx if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.deleteProvisioning202Accepted200SucceededHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -848,7 +839,6 @@ func (client *lrOSOperations) ResumeDeleteProvisioning202Accepted200Succeeded(to return &productPoller{ pipeline: client.p, pt: pt, - response: client.deleteProvisioning202Accepted200SucceededHandleResponse, }, nil } @@ -900,13 +890,13 @@ func (client *lrOSOperations) BeginDeleteProvisioning202DeletingFailed200(ctx co if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.deleteProvisioning202DeletingFailed200HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -919,7 +909,6 @@ func (client *lrOSOperations) ResumeDeleteProvisioning202DeletingFailed200(token return &productPoller{ pipeline: client.p, pt: pt, - response: client.deleteProvisioning202DeletingFailed200HandleResponse, }, nil } @@ -971,13 +960,13 @@ func (client *lrOSOperations) BeginDeleteProvisioning202Deletingcanceled200(ctx if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.deleteProvisioning202Deletingcanceled200HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -990,7 +979,6 @@ func (client *lrOSOperations) ResumeDeleteProvisioning202Deletingcanceled200(tok return &productPoller{ pipeline: client.p, pt: pt, - response: client.deleteProvisioning202Deletingcanceled200HandleResponse, }, nil } @@ -1042,13 +1030,13 @@ func (client *lrOSOperations) BeginPost200WithPayload(ctx context.Context) (*Sku if err != nil { return nil, err } - result.Poller = &skuPoller{ + poller := &skuPoller{ pt: pt, pipeline: client.p, - response: client.post200WithPayloadHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*SkuResponse, error) { - return skuPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1061,7 +1049,6 @@ func (client *lrOSOperations) ResumePost200WithPayload(token string) (SkuPoller, return &skuPoller{ pipeline: client.p, pt: pt, - response: client.post200WithPayloadHandleResponse, }, nil } @@ -1113,13 +1100,13 @@ func (client *lrOSOperations) BeginPost202NoRetry204(ctx context.Context, lrOSPo if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.post202NoRetry204HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1132,7 +1119,6 @@ func (client *lrOSOperations) ResumePost202NoRetry204(token string) (ProductPoll return &productPoller{ pipeline: client.p, pt: pt, - response: client.post202NoRetry204HandleResponse, }, nil } @@ -1187,13 +1173,13 @@ func (client *lrOSOperations) BeginPost202Retry200(ctx context.Context, lrOSPost if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.post202Retry200HandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1206,7 +1192,6 @@ func (client *lrOSOperations) ResumePost202Retry200(token string) (HTTPPoller, e return &httpPoller{ pipeline: client.p, pt: pt, - response: client.post202Retry200HandleResponse, }, nil } @@ -1260,13 +1245,13 @@ func (client *lrOSOperations) BeginPostAsyncNoRetrySucceeded(ctx context.Context if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.postAsyncNoRetrySucceededHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1279,7 +1264,6 @@ func (client *lrOSOperations) ResumePostAsyncNoRetrySucceeded(token string) (Pro return &productPoller{ pipeline: client.p, pt: pt, - response: client.postAsyncNoRetrySucceededHandleResponse, }, nil } @@ -1334,13 +1318,13 @@ func (client *lrOSOperations) BeginPostAsyncRetryFailed(ctx context.Context, lrO if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.postAsyncRetryFailedHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1353,7 +1337,6 @@ func (client *lrOSOperations) ResumePostAsyncRetryFailed(token string) (HTTPPoll return &httpPoller{ pipeline: client.p, pt: pt, - response: client.postAsyncRetryFailedHandleResponse, }, nil } @@ -1407,13 +1390,13 @@ func (client *lrOSOperations) BeginPostAsyncRetrySucceeded(ctx context.Context, if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.postAsyncRetrySucceededHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1426,7 +1409,6 @@ func (client *lrOSOperations) ResumePostAsyncRetrySucceeded(token string) (Produ return &productPoller{ pipeline: client.p, pt: pt, - response: client.postAsyncRetrySucceededHandleResponse, }, nil } @@ -1481,13 +1463,13 @@ func (client *lrOSOperations) BeginPostAsyncRetrycanceled(ctx context.Context, l if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.postAsyncRetrycanceledHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1500,7 +1482,6 @@ func (client *lrOSOperations) ResumePostAsyncRetrycanceled(token string) (HTTPPo return &httpPoller{ pipeline: client.p, pt: pt, - response: client.postAsyncRetrycanceledHandleResponse, }, nil } @@ -1554,13 +1535,13 @@ func (client *lrOSOperations) BeginPostDoubleHeadersFinalAzureHeaderGet(ctx cont if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.postDoubleHeadersFinalAzureHeaderGetHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1573,7 +1554,6 @@ func (client *lrOSOperations) ResumePostDoubleHeadersFinalAzureHeaderGet(token s return &productPoller{ pipeline: client.p, pt: pt, - response: client.postDoubleHeadersFinalAzureHeaderGetHandleResponse, }, nil } @@ -1625,13 +1605,13 @@ func (client *lrOSOperations) BeginPostDoubleHeadersFinalAzureHeaderGetDefault(c if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.postDoubleHeadersFinalAzureHeaderGetDefaultHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1644,7 +1624,6 @@ func (client *lrOSOperations) ResumePostDoubleHeadersFinalAzureHeaderGetDefault( return &productPoller{ pipeline: client.p, pt: pt, - response: client.postDoubleHeadersFinalAzureHeaderGetDefaultHandleResponse, }, nil } @@ -1696,13 +1675,13 @@ func (client *lrOSOperations) BeginPostDoubleHeadersFinalLocationGet(ctx context if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.postDoubleHeadersFinalLocationGetHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1715,7 +1694,6 @@ func (client *lrOSOperations) ResumePostDoubleHeadersFinalLocationGet(token stri return &productPoller{ pipeline: client.p, pt: pt, - response: client.postDoubleHeadersFinalLocationGetHandleResponse, }, nil } @@ -1767,13 +1745,13 @@ func (client *lrOSOperations) BeginPut200Acceptedcanceled200(ctx context.Context if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.put200Acceptedcanceled200HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1786,7 +1764,6 @@ func (client *lrOSOperations) ResumePut200Acceptedcanceled200(token string) (Pro return &productPoller{ pipeline: client.p, pt: pt, - response: client.put200Acceptedcanceled200HandleResponse, }, nil } @@ -1841,13 +1818,13 @@ func (client *lrOSOperations) BeginPut200Succeeded(ctx context.Context, lrOSPut2 if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.put200SucceededHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1860,7 +1837,6 @@ func (client *lrOSOperations) ResumePut200Succeeded(token string) (ProductPoller return &productPoller{ pipeline: client.p, pt: pt, - response: client.put200SucceededHandleResponse, }, nil } @@ -1915,13 +1891,13 @@ func (client *lrOSOperations) BeginPut200SucceededNoState(ctx context.Context, l if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.put200SucceededNoStateHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1934,7 +1910,6 @@ func (client *lrOSOperations) ResumePut200SucceededNoState(token string) (Produc return &productPoller{ pipeline: client.p, pt: pt, - response: client.put200SucceededNoStateHandleResponse, }, nil } @@ -1989,13 +1964,13 @@ func (client *lrOSOperations) BeginPut200UpdatingSucceeded204(ctx context.Contex if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.put200UpdatingSucceeded204HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -2008,7 +1983,6 @@ func (client *lrOSOperations) ResumePut200UpdatingSucceeded204(token string) (Pr return &productPoller{ pipeline: client.p, pt: pt, - response: client.put200UpdatingSucceeded204HandleResponse, }, nil } @@ -2063,13 +2037,13 @@ func (client *lrOSOperations) BeginPut201CreatingFailed200(ctx context.Context, if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.put201CreatingFailed200HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -2082,7 +2056,6 @@ func (client *lrOSOperations) ResumePut201CreatingFailed200(token string) (Produ return &productPoller{ pipeline: client.p, pt: pt, - response: client.put201CreatingFailed200HandleResponse, }, nil } @@ -2137,13 +2110,13 @@ func (client *lrOSOperations) BeginPut201CreatingSucceeded200(ctx context.Contex if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.put201CreatingSucceeded200HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -2156,7 +2129,6 @@ func (client *lrOSOperations) ResumePut201CreatingSucceeded200(token string) (Pr return &productPoller{ pipeline: client.p, pt: pt, - response: client.put201CreatingSucceeded200HandleResponse, }, nil } @@ -2211,13 +2183,13 @@ func (client *lrOSOperations) BeginPut202Retry200(ctx context.Context, lrOSPut20 if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.put202Retry200HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -2230,7 +2202,6 @@ func (client *lrOSOperations) ResumePut202Retry200(token string) (ProductPoller, return &productPoller{ pipeline: client.p, pt: pt, - response: client.put202Retry200HandleResponse, }, nil } @@ -2285,13 +2256,13 @@ func (client *lrOSOperations) BeginPutAsyncNoHeaderInRetry(ctx context.Context, if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putAsyncNoHeaderInRetryHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -2304,7 +2275,6 @@ func (client *lrOSOperations) ResumePutAsyncNoHeaderInRetry(token string) (Produ return &productPoller{ pipeline: client.p, pt: pt, - response: client.putAsyncNoHeaderInRetryHandleResponse, }, nil } @@ -2359,13 +2329,13 @@ func (client *lrOSOperations) BeginPutAsyncNoRetrySucceeded(ctx context.Context, if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putAsyncNoRetrySucceededHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -2378,7 +2348,6 @@ func (client *lrOSOperations) ResumePutAsyncNoRetrySucceeded(token string) (Prod return &productPoller{ pipeline: client.p, pt: pt, - response: client.putAsyncNoRetrySucceededHandleResponse, }, nil } @@ -2433,13 +2402,13 @@ func (client *lrOSOperations) BeginPutAsyncNoRetrycanceled(ctx context.Context, if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putAsyncNoRetrycanceledHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -2452,7 +2421,6 @@ func (client *lrOSOperations) ResumePutAsyncNoRetrycanceled(token string) (Produ return &productPoller{ pipeline: client.p, pt: pt, - response: client.putAsyncNoRetrycanceledHandleResponse, }, nil } @@ -2507,13 +2475,13 @@ func (client *lrOSOperations) BeginPutAsyncNonResource(ctx context.Context, lrOS if err != nil { return nil, err } - result.Poller = &skuPoller{ + poller := &skuPoller{ pt: pt, pipeline: client.p, - response: client.putAsyncNonResourceHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*SkuResponse, error) { - return skuPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -2526,7 +2494,6 @@ func (client *lrOSOperations) ResumePutAsyncNonResource(token string) (SkuPoller return &skuPoller{ pipeline: client.p, pt: pt, - response: client.putAsyncNonResourceHandleResponse, }, nil } @@ -2581,13 +2548,13 @@ func (client *lrOSOperations) BeginPutAsyncRetryFailed(ctx context.Context, lrOS if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putAsyncRetryFailedHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -2600,7 +2567,6 @@ func (client *lrOSOperations) ResumePutAsyncRetryFailed(token string) (ProductPo return &productPoller{ pipeline: client.p, pt: pt, - response: client.putAsyncRetryFailedHandleResponse, }, nil } @@ -2655,13 +2621,13 @@ func (client *lrOSOperations) BeginPutAsyncRetrySucceeded(ctx context.Context, l if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putAsyncRetrySucceededHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -2674,7 +2640,6 @@ func (client *lrOSOperations) ResumePutAsyncRetrySucceeded(token string) (Produc return &productPoller{ pipeline: client.p, pt: pt, - response: client.putAsyncRetrySucceededHandleResponse, }, nil } @@ -2729,13 +2694,13 @@ func (client *lrOSOperations) BeginPutAsyncSubResource(ctx context.Context, lrOS if err != nil { return nil, err } - result.Poller = &subProductPoller{ + poller := &subProductPoller{ pt: pt, pipeline: client.p, - response: client.putAsyncSubResourceHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*SubProductResponse, error) { - return subProductPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -2748,7 +2713,6 @@ func (client *lrOSOperations) ResumePutAsyncSubResource(token string) (SubProduc return &subProductPoller{ pipeline: client.p, pt: pt, - response: client.putAsyncSubResourceHandleResponse, }, nil } @@ -2803,13 +2767,13 @@ func (client *lrOSOperations) BeginPutNoHeaderInRetry(ctx context.Context, lrOSP if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putNoHeaderInRetryHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -2822,7 +2786,6 @@ func (client *lrOSOperations) ResumePutNoHeaderInRetry(token string) (ProductPol return &productPoller{ pipeline: client.p, pt: pt, - response: client.putNoHeaderInRetryHandleResponse, }, nil } @@ -2877,13 +2840,13 @@ func (client *lrOSOperations) BeginPutNonResource(ctx context.Context, lrOSPutNo if err != nil { return nil, err } - result.Poller = &skuPoller{ + poller := &skuPoller{ pt: pt, pipeline: client.p, - response: client.putNonResourceHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*SkuResponse, error) { - return skuPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -2896,7 +2859,6 @@ func (client *lrOSOperations) ResumePutNonResource(token string) (SkuPoller, err return &skuPoller{ pipeline: client.p, pt: pt, - response: client.putNonResourceHandleResponse, }, nil } @@ -2951,13 +2913,13 @@ func (client *lrOSOperations) BeginPutSubResource(ctx context.Context, lrOSPutSu if err != nil { return nil, err } - result.Poller = &subProductPoller{ + poller := &subProductPoller{ pt: pt, pipeline: client.p, - response: client.putSubResourceHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*SubProductResponse, error) { - return subProductPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -2970,7 +2932,6 @@ func (client *lrOSOperations) ResumePutSubResource(token string) (SubProductPoll return &subProductPoller{ pipeline: client.p, pt: pt, - response: client.putSubResourceHandleResponse, }, nil } diff --git a/test/autorest/generated/lrogroup/lrosads.go b/test/autorest/generated/lrogroup/lrosads.go index f8999228b..97e2133c0 100644 --- a/test/autorest/generated/lrogroup/lrosads.go +++ b/test/autorest/generated/lrogroup/lrosads.go @@ -144,13 +144,13 @@ func (client *lrosaDsOperations) BeginDelete202NonRetry400(ctx context.Context) if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.delete202NonRetry400HandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -163,7 +163,6 @@ func (client *lrosaDsOperations) ResumeDelete202NonRetry400(token string) (HTTPP return &httpPoller{ pipeline: client.p, pt: pt, - response: client.delete202NonRetry400HandleResponse, }, nil } @@ -214,13 +213,13 @@ func (client *lrosaDsOperations) BeginDelete202RetryInvalidHeader(ctx context.Co if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.delete202RetryInvalidHeaderHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -233,7 +232,6 @@ func (client *lrosaDsOperations) ResumeDelete202RetryInvalidHeader(token string) return &httpPoller{ pipeline: client.p, pt: pt, - response: client.delete202RetryInvalidHeaderHandleResponse, }, nil } @@ -284,13 +282,13 @@ func (client *lrosaDsOperations) BeginDelete204Succeeded(ctx context.Context) (* if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.delete204SucceededHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -303,7 +301,6 @@ func (client *lrosaDsOperations) ResumeDelete204Succeeded(token string) (HTTPPol return &httpPoller{ pipeline: client.p, pt: pt, - response: client.delete204SucceededHandleResponse, }, nil } @@ -354,13 +351,13 @@ func (client *lrosaDsOperations) BeginDeleteAsyncRelativeRetry400(ctx context.Co if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.deleteAsyncRelativeRetry400HandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -373,7 +370,6 @@ func (client *lrosaDsOperations) ResumeDeleteAsyncRelativeRetry400(token string) return &httpPoller{ pipeline: client.p, pt: pt, - response: client.deleteAsyncRelativeRetry400HandleResponse, }, nil } @@ -424,13 +420,13 @@ func (client *lrosaDsOperations) BeginDeleteAsyncRelativeRetryInvalidHeader(ctx if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.deleteAsyncRelativeRetryInvalidHeaderHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -443,7 +439,6 @@ func (client *lrosaDsOperations) ResumeDeleteAsyncRelativeRetryInvalidHeader(tok return &httpPoller{ pipeline: client.p, pt: pt, - response: client.deleteAsyncRelativeRetryInvalidHeaderHandleResponse, }, nil } @@ -494,13 +489,13 @@ func (client *lrosaDsOperations) BeginDeleteAsyncRelativeRetryInvalidJSONPolling if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.deleteAsyncRelativeRetryInvalidJsonPollingHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -513,7 +508,6 @@ func (client *lrosaDsOperations) ResumeDeleteAsyncRelativeRetryInvalidJSONPollin return &httpPoller{ pipeline: client.p, pt: pt, - response: client.deleteAsyncRelativeRetryInvalidJsonPollingHandleResponse, }, nil } @@ -564,13 +558,13 @@ func (client *lrosaDsOperations) BeginDeleteAsyncRelativeRetryNoStatus(ctx conte if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.deleteAsyncRelativeRetryNoStatusHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -583,7 +577,6 @@ func (client *lrosaDsOperations) ResumeDeleteAsyncRelativeRetryNoStatus(token st return &httpPoller{ pipeline: client.p, pt: pt, - response: client.deleteAsyncRelativeRetryNoStatusHandleResponse, }, nil } @@ -634,13 +627,13 @@ func (client *lrosaDsOperations) BeginDeleteNonRetry400(ctx context.Context) (*H if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.deleteNonRetry400HandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -653,7 +646,6 @@ func (client *lrosaDsOperations) ResumeDeleteNonRetry400(token string) (HTTPPoll return &httpPoller{ pipeline: client.p, pt: pt, - response: client.deleteNonRetry400HandleResponse, }, nil } @@ -704,13 +696,13 @@ func (client *lrosaDsOperations) BeginPost202NoLocation(ctx context.Context, lro if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.post202NoLocationHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -723,7 +715,6 @@ func (client *lrosaDsOperations) ResumePost202NoLocation(token string) (HTTPPoll return &httpPoller{ pipeline: client.p, pt: pt, - response: client.post202NoLocationHandleResponse, }, nil } @@ -777,13 +768,13 @@ func (client *lrosaDsOperations) BeginPost202NonRetry400(ctx context.Context, lr if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.post202NonRetry400HandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -796,7 +787,6 @@ func (client *lrosaDsOperations) ResumePost202NonRetry400(token string) (HTTPPol return &httpPoller{ pipeline: client.p, pt: pt, - response: client.post202NonRetry400HandleResponse, }, nil } @@ -850,13 +840,13 @@ func (client *lrosaDsOperations) BeginPost202RetryInvalidHeader(ctx context.Cont if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.post202RetryInvalidHeaderHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -869,7 +859,6 @@ func (client *lrosaDsOperations) ResumePost202RetryInvalidHeader(token string) ( return &httpPoller{ pipeline: client.p, pt: pt, - response: client.post202RetryInvalidHeaderHandleResponse, }, nil } @@ -923,13 +912,13 @@ func (client *lrosaDsOperations) BeginPostAsyncRelativeRetry400(ctx context.Cont if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.postAsyncRelativeRetry400HandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -942,7 +931,6 @@ func (client *lrosaDsOperations) ResumePostAsyncRelativeRetry400(token string) ( return &httpPoller{ pipeline: client.p, pt: pt, - response: client.postAsyncRelativeRetry400HandleResponse, }, nil } @@ -996,13 +984,13 @@ func (client *lrosaDsOperations) BeginPostAsyncRelativeRetryInvalidHeader(ctx co if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.postAsyncRelativeRetryInvalidHeaderHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1015,7 +1003,6 @@ func (client *lrosaDsOperations) ResumePostAsyncRelativeRetryInvalidHeader(token return &httpPoller{ pipeline: client.p, pt: pt, - response: client.postAsyncRelativeRetryInvalidHeaderHandleResponse, }, nil } @@ -1069,13 +1056,13 @@ func (client *lrosaDsOperations) BeginPostAsyncRelativeRetryInvalidJSONPolling(c if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.postAsyncRelativeRetryInvalidJsonPollingHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1088,7 +1075,6 @@ func (client *lrosaDsOperations) ResumePostAsyncRelativeRetryInvalidJSONPolling( return &httpPoller{ pipeline: client.p, pt: pt, - response: client.postAsyncRelativeRetryInvalidJsonPollingHandleResponse, }, nil } @@ -1142,13 +1128,13 @@ func (client *lrosaDsOperations) BeginPostAsyncRelativeRetryNoPayload(ctx contex if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.postAsyncRelativeRetryNoPayloadHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1161,7 +1147,6 @@ func (client *lrosaDsOperations) ResumePostAsyncRelativeRetryNoPayload(token str return &httpPoller{ pipeline: client.p, pt: pt, - response: client.postAsyncRelativeRetryNoPayloadHandleResponse, }, nil } @@ -1215,13 +1200,13 @@ func (client *lrosaDsOperations) BeginPostNonRetry400(ctx context.Context, lrosa if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.postNonRetry400HandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1234,7 +1219,6 @@ func (client *lrosaDsOperations) ResumePostNonRetry400(token string) (HTTPPoller return &httpPoller{ pipeline: client.p, pt: pt, - response: client.postNonRetry400HandleResponse, }, nil } @@ -1288,13 +1272,13 @@ func (client *lrosaDsOperations) BeginPut200InvalidJSON(ctx context.Context, lro if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.put200InvalidJsonHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1307,7 +1291,6 @@ func (client *lrosaDsOperations) ResumePut200InvalidJSON(token string) (ProductP return &productPoller{ pipeline: client.p, pt: pt, - response: client.put200InvalidJsonHandleResponse, }, nil } @@ -1362,13 +1345,13 @@ func (client *lrosaDsOperations) BeginPutAsyncRelativeRetry400(ctx context.Conte if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putAsyncRelativeRetry400HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1381,7 +1364,6 @@ func (client *lrosaDsOperations) ResumePutAsyncRelativeRetry400(token string) (P return &productPoller{ pipeline: client.p, pt: pt, - response: client.putAsyncRelativeRetry400HandleResponse, }, nil } @@ -1436,13 +1418,13 @@ func (client *lrosaDsOperations) BeginPutAsyncRelativeRetryInvalidHeader(ctx con if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putAsyncRelativeRetryInvalidHeaderHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1455,7 +1437,6 @@ func (client *lrosaDsOperations) ResumePutAsyncRelativeRetryInvalidHeader(token return &productPoller{ pipeline: client.p, pt: pt, - response: client.putAsyncRelativeRetryInvalidHeaderHandleResponse, }, nil } @@ -1510,13 +1491,13 @@ func (client *lrosaDsOperations) BeginPutAsyncRelativeRetryInvalidJSONPolling(ct if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putAsyncRelativeRetryInvalidJsonPollingHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1529,7 +1510,6 @@ func (client *lrosaDsOperations) ResumePutAsyncRelativeRetryInvalidJSONPolling(t return &productPoller{ pipeline: client.p, pt: pt, - response: client.putAsyncRelativeRetryInvalidJsonPollingHandleResponse, }, nil } @@ -1584,13 +1564,13 @@ func (client *lrosaDsOperations) BeginPutAsyncRelativeRetryNoStatus(ctx context. if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putAsyncRelativeRetryNoStatusHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1603,7 +1583,6 @@ func (client *lrosaDsOperations) ResumePutAsyncRelativeRetryNoStatus(token strin return &productPoller{ pipeline: client.p, pt: pt, - response: client.putAsyncRelativeRetryNoStatusHandleResponse, }, nil } @@ -1658,13 +1637,13 @@ func (client *lrosaDsOperations) BeginPutAsyncRelativeRetryNoStatusPayload(ctx c if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putAsyncRelativeRetryNoStatusPayloadHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1677,7 +1656,6 @@ func (client *lrosaDsOperations) ResumePutAsyncRelativeRetryNoStatusPayload(toke return &productPoller{ pipeline: client.p, pt: pt, - response: client.putAsyncRelativeRetryNoStatusPayloadHandleResponse, }, nil } @@ -1732,13 +1710,13 @@ func (client *lrosaDsOperations) BeginPutError201NoProvisioningStatePayload(ctx if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putError201NoProvisioningStatePayloadHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1751,7 +1729,6 @@ func (client *lrosaDsOperations) ResumePutError201NoProvisioningStatePayload(tok return &productPoller{ pipeline: client.p, pt: pt, - response: client.putError201NoProvisioningStatePayloadHandleResponse, }, nil } @@ -1806,13 +1783,13 @@ func (client *lrosaDsOperations) BeginPutNonRetry201Creating400(ctx context.Cont if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putNonRetry201Creating400HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1825,7 +1802,6 @@ func (client *lrosaDsOperations) ResumePutNonRetry201Creating400(token string) ( return &productPoller{ pipeline: client.p, pt: pt, - response: client.putNonRetry201Creating400HandleResponse, }, nil } @@ -1880,13 +1856,13 @@ func (client *lrosaDsOperations) BeginPutNonRetry201Creating400InvalidJSON(ctx c if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putNonRetry201Creating400InvalidJsonHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1899,7 +1875,6 @@ func (client *lrosaDsOperations) ResumePutNonRetry201Creating400InvalidJSON(toke return &productPoller{ pipeline: client.p, pt: pt, - response: client.putNonRetry201Creating400InvalidJsonHandleResponse, }, nil } @@ -1954,13 +1929,13 @@ func (client *lrosaDsOperations) BeginPutNonRetry400(ctx context.Context, lrosaD if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putNonRetry400HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -1973,7 +1948,6 @@ func (client *lrosaDsOperations) ResumePutNonRetry400(token string) (ProductPoll return &productPoller{ pipeline: client.p, pt: pt, - response: client.putNonRetry400HandleResponse, }, nil } diff --git a/test/autorest/generated/lrogroup/lroscustomheader.go b/test/autorest/generated/lrogroup/lroscustomheader.go index 687366813..d43ce059e 100644 --- a/test/autorest/generated/lrogroup/lroscustomheader.go +++ b/test/autorest/generated/lrogroup/lroscustomheader.go @@ -56,13 +56,13 @@ func (client *lrOSCustomHeaderOperations) BeginPost202Retry200(ctx context.Conte if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.post202Retry200HandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -75,7 +75,6 @@ func (client *lrOSCustomHeaderOperations) ResumePost202Retry200(token string) (H return &httpPoller{ pipeline: client.p, pt: pt, - response: client.post202Retry200HandleResponse, }, nil } @@ -129,13 +128,13 @@ func (client *lrOSCustomHeaderOperations) BeginPostAsyncRetrySucceeded(ctx conte if err != nil { return nil, err } - result.Poller = &httpPoller{ + poller := &httpPoller{ pt: pt, pipeline: client.p, - response: client.postAsyncRetrySucceededHandleResponse, } - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) { - return httpPollerPollUntilDone(ctx, result.Poller, frequency) + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -148,7 +147,6 @@ func (client *lrOSCustomHeaderOperations) ResumePostAsyncRetrySucceeded(token st return &httpPoller{ pipeline: client.p, pt: pt, - response: client.postAsyncRetrySucceededHandleResponse, }, nil } @@ -202,13 +200,13 @@ func (client *lrOSCustomHeaderOperations) BeginPut201CreatingSucceeded200(ctx co if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.put201CreatingSucceeded200HandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -221,7 +219,6 @@ func (client *lrOSCustomHeaderOperations) ResumePut201CreatingSucceeded200(token return &productPoller{ pipeline: client.p, pt: pt, - response: client.put201CreatingSucceeded200HandleResponse, }, nil } @@ -276,13 +273,13 @@ func (client *lrOSCustomHeaderOperations) BeginPutAsyncRetrySucceeded(ctx contex if err != nil { return nil, err } - result.Poller = &productPoller{ + poller := &productPoller{ pt: pt, pipeline: client.p, - response: client.putAsyncRetrySucceededHandleResponse, } + result.Poller = poller result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { - return productPollerPollUntilDone(ctx, result.Poller, frequency) + return poller.pollUntilDone(ctx, frequency) } return result, nil } @@ -295,7 +292,6 @@ func (client *lrOSCustomHeaderOperations) ResumePutAsyncRetrySucceeded(token str return &productPoller{ pipeline: client.p, pt: pt, - response: client.putAsyncRetrySucceededHandleResponse, }, nil } diff --git a/test/autorest/generated/lrogroup/models.go b/test/autorest/generated/lrogroup/models.go index 9a046a46e..3a18ee7f2 100644 --- a/test/autorest/generated/lrogroup/models.go +++ b/test/autorest/generated/lrogroup/models.go @@ -34,7 +34,7 @@ func (e CloudError) Error() string { // HTTPResponse contains the HTTP response from the call to the service endpoint type HTTPResponse struct { // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received - PollUntilDone func(ctx context.Context, frequency time.Duration) (*HTTPResponse, error) + PollUntilDone func(ctx context.Context, frequency time.Duration) (*http.Response, error) // Poller contains an initialized poller Poller HTTPPoller diff --git a/test/autorest/generated/lrogroup/pollers.go b/test/autorest/generated/lrogroup/pollers.go index cdb477c02..f2789c8b5 100644 --- a/test/autorest/generated/lrogroup/pollers.go +++ b/test/autorest/generated/lrogroup/pollers.go @@ -19,19 +19,15 @@ import ( type HTTPPoller interface { Done() bool Poll(ctx context.Context) (*http.Response, error) - FinalResponse(ctx context.Context) (*HTTPResponse, error) + FinalResponse() *http.Response ResumeToken() (string, error) } -type httpResponseHandleResponse func(*azcore.Response) (*HTTPResponse, error) - type httpPoller struct { // the client for making the request pipeline azcore.Pipeline // polling tracker pt pollingTracker - // use the response handler to check for accepted status codes - response httpResponseHandleResponse } // Done returns true if there was an error or polling has reached a terminal state @@ -47,33 +43,8 @@ func (p *httpPoller) Poll(ctx context.Context) (*http.Response, error) { return nil, p.pt.pollingError() } -func (p *httpPoller) FinalResponse(ctx context.Context) (*HTTPResponse, error) { - if p.pt.finalGetURL() == "" { - // we can end up in this situation if the async operation returns a 200 - // with no polling URLs. in that case return the response which should - // contain the JSON payload (only do this for successful terminal cases). - if lr := p.pt.latestResponse(); lr != nil && p.pt.hasSucceeded() { - result, err := p.response(lr) - if err != nil { - return nil, err - } - return result, nil - } - return nil, errors.New("missing URL for retrieving result") - } - u, err := url.Parse(p.pt.finalGetURL()) - if err != nil { - return nil, err - } - req := azcore.NewRequest(http.MethodGet, *u) - if err != nil { - return nil, err - } - resp, err := p.pipeline.Do(ctx, req) - if err != nil { - return nil, err - } - return p.response(resp) +func (p *httpPoller) FinalResponse() *http.Response { + return p.pt.latestResponse().Response } // ResumeToken generates the string token that can be used with the ResumeHTTPPoller method @@ -89,19 +60,22 @@ func (p *httpPoller) ResumeToken() (string, error) { return string(js), nil } -func httpPollerPollUntilDone(ctx context.Context, p HTTPPoller, frequency time.Duration) (*HTTPResponse, error) { - for !p.Done() { +func (p *httpPoller) pollUntilDone(ctx context.Context, frequency time.Duration) (*http.Response, error) { + for { resp, err := p.Poll(ctx) if err != nil { return nil, err } + if p.Done() { + break + } if delay := azcore.RetryAfter(resp); delay > 0 { time.Sleep(delay) } else { time.Sleep(frequency) } } - return p.FinalResponse(ctx) + return p.FinalResponse(), nil } // ProductPoller provides polling facilities until the operation completes @@ -112,15 +86,11 @@ type ProductPoller interface { ResumeToken() (string, error) } -type productHandleResponse func(*azcore.Response) (*ProductResponse, error) - type productPoller struct { // the client for making the request pipeline azcore.Pipeline // polling tracker pt pollingTracker - // use the response handler to check for accepted status codes - response productHandleResponse } // Done returns true if there was an error or polling has reached a terminal state @@ -142,7 +112,7 @@ func (p *productPoller) FinalResponse(ctx context.Context) (*ProductResponse, er // with no polling URLs. in that case return the response which should // contain the JSON payload (only do this for successful terminal cases). if lr := p.pt.latestResponse(); lr != nil && p.pt.hasSucceeded() { - result, err := p.response(lr) + result, err := p.handleResponse(lr) if err != nil { return nil, err } @@ -162,7 +132,7 @@ func (p *productPoller) FinalResponse(ctx context.Context) (*ProductResponse, er if err != nil { return nil, err } - return p.response(resp) + return p.handleResponse(resp) } // ResumeToken generates the string token that can be used with the ResumeProductPoller method @@ -178,12 +148,15 @@ func (p *productPoller) ResumeToken() (string, error) { return string(js), nil } -func productPollerPollUntilDone(ctx context.Context, p ProductPoller, frequency time.Duration) (*ProductResponse, error) { - for !p.Done() { +func (p *productPoller) pollUntilDone(ctx context.Context, frequency time.Duration) (*ProductResponse, error) { + for { resp, err := p.Poll(ctx) if err != nil { return nil, err } + if p.Done() { + break + } if delay := azcore.RetryAfter(resp); delay > 0 { time.Sleep(delay) } else { @@ -193,6 +166,17 @@ func productPollerPollUntilDone(ctx context.Context, p ProductPoller, frequency return p.FinalResponse(ctx) } +func (p *productPoller) handleResponse(resp *azcore.Response) (*ProductResponse, error) { + result := ProductResponse{RawResponse: resp.Response} + if resp.HasStatusCode(http.StatusNoContent) { + return &result, nil + } + if !resp.HasStatusCode(pollingCodes[:]...) { + return nil, p.pt.handleError(resp) + } + return &result, resp.UnmarshalAsJSON(&result.Product) +} + // SkuPoller provides polling facilities until the operation completes type SkuPoller interface { Done() bool @@ -201,15 +185,11 @@ type SkuPoller interface { ResumeToken() (string, error) } -type skuHandleResponse func(*azcore.Response) (*SkuResponse, error) - type skuPoller struct { // the client for making the request pipeline azcore.Pipeline // polling tracker pt pollingTracker - // use the response handler to check for accepted status codes - response skuHandleResponse } // Done returns true if there was an error or polling has reached a terminal state @@ -231,7 +211,7 @@ func (p *skuPoller) FinalResponse(ctx context.Context) (*SkuResponse, error) { // with no polling URLs. in that case return the response which should // contain the JSON payload (only do this for successful terminal cases). if lr := p.pt.latestResponse(); lr != nil && p.pt.hasSucceeded() { - result, err := p.response(lr) + result, err := p.handleResponse(lr) if err != nil { return nil, err } @@ -251,7 +231,7 @@ func (p *skuPoller) FinalResponse(ctx context.Context) (*SkuResponse, error) { if err != nil { return nil, err } - return p.response(resp) + return p.handleResponse(resp) } // ResumeToken generates the string token that can be used with the ResumeSkuPoller method @@ -267,12 +247,15 @@ func (p *skuPoller) ResumeToken() (string, error) { return string(js), nil } -func skuPollerPollUntilDone(ctx context.Context, p SkuPoller, frequency time.Duration) (*SkuResponse, error) { - for !p.Done() { +func (p *skuPoller) pollUntilDone(ctx context.Context, frequency time.Duration) (*SkuResponse, error) { + for { resp, err := p.Poll(ctx) if err != nil { return nil, err } + if p.Done() { + break + } if delay := azcore.RetryAfter(resp); delay > 0 { time.Sleep(delay) } else { @@ -282,6 +265,17 @@ func skuPollerPollUntilDone(ctx context.Context, p SkuPoller, frequency time.Dur return p.FinalResponse(ctx) } +func (p *skuPoller) handleResponse(resp *azcore.Response) (*SkuResponse, error) { + result := SkuResponse{RawResponse: resp.Response} + if resp.HasStatusCode(http.StatusNoContent) { + return &result, nil + } + if !resp.HasStatusCode(pollingCodes[:]...) { + return nil, p.pt.handleError(resp) + } + return &result, resp.UnmarshalAsJSON(&result.Sku) +} + // SubProductPoller provides polling facilities until the operation completes type SubProductPoller interface { Done() bool @@ -290,15 +284,11 @@ type SubProductPoller interface { ResumeToken() (string, error) } -type subProductHandleResponse func(*azcore.Response) (*SubProductResponse, error) - type subProductPoller struct { // the client for making the request pipeline azcore.Pipeline // polling tracker pt pollingTracker - // use the response handler to check for accepted status codes - response subProductHandleResponse } // Done returns true if there was an error or polling has reached a terminal state @@ -320,7 +310,7 @@ func (p *subProductPoller) FinalResponse(ctx context.Context) (*SubProductRespon // with no polling URLs. in that case return the response which should // contain the JSON payload (only do this for successful terminal cases). if lr := p.pt.latestResponse(); lr != nil && p.pt.hasSucceeded() { - result, err := p.response(lr) + result, err := p.handleResponse(lr) if err != nil { return nil, err } @@ -340,7 +330,7 @@ func (p *subProductPoller) FinalResponse(ctx context.Context) (*SubProductRespon if err != nil { return nil, err } - return p.response(resp) + return p.handleResponse(resp) } // ResumeToken generates the string token that can be used with the ResumeSubProductPoller method @@ -356,12 +346,15 @@ func (p *subProductPoller) ResumeToken() (string, error) { return string(js), nil } -func subProductPollerPollUntilDone(ctx context.Context, p SubProductPoller, frequency time.Duration) (*SubProductResponse, error) { - for !p.Done() { +func (p *subProductPoller) pollUntilDone(ctx context.Context, frequency time.Duration) (*SubProductResponse, error) { + for { resp, err := p.Poll(ctx) if err != nil { return nil, err } + if p.Done() { + break + } if delay := azcore.RetryAfter(resp); delay > 0 { time.Sleep(delay) } else { @@ -370,3 +363,14 @@ func subProductPollerPollUntilDone(ctx context.Context, p SubProductPoller, freq } return p.FinalResponse(ctx) } + +func (p *subProductPoller) handleResponse(resp *azcore.Response) (*SubProductResponse, error) { + result := SubProductResponse{RawResponse: resp.Response} + if resp.HasStatusCode(http.StatusNoContent) { + return &result, nil + } + if !resp.HasStatusCode(pollingCodes[:]...) { + return nil, p.pt.handleError(resp) + } + return &result, resp.UnmarshalAsJSON(&result.SubProduct) +} diff --git a/test/autorest/generated/lrogroup/pollers_helper.go b/test/autorest/generated/lrogroup/pollers_helper.go index c26dc2953..a237490e5 100644 --- a/test/autorest/generated/lrogroup/pollers_helper.go +++ b/test/autorest/generated/lrogroup/pollers_helper.go @@ -84,6 +84,9 @@ type pollingTracker interface { // returns the cached HTTP response after a call to pollForStatus(), can be nil latestResponse() *azcore.Response + + // converts an *azcore.Response to an error + handleError(resp *azcore.Response) error } type methodErrorHandler func(resp *azcore.Response) error @@ -342,6 +345,10 @@ func (pt *pollingTrackerBase) initPollingMethod() error { return nil } +func (pt *pollingTrackerBase) handleError(resp *azcore.Response) error { + return pt.errorHandler(resp) +} + // DELETE type pollingTrackerDelete struct { diff --git a/test/autorest/lrogroup/lros_test.go b/test/autorest/lrogroup/lros_test.go index 561803298..7d70e01e8 100644 --- a/test/autorest/lrogroup/lros_test.go +++ b/test/autorest/lrogroup/lros_test.go @@ -12,6 +12,8 @@ import ( "testing" "time" + "github.com/Azure/azure-sdk-for-go/sdk/to" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" ) @@ -37,22 +39,26 @@ func httpClientWithCookieJar() azcore.Transport { }) } -// func TestLROResumeWrongPoller(t *testing.T) { -// op := getLROSOperations(t) -// resp, err := op.Delete202NoRetry204(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// poller := resp.GetPoller() -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// _, err = op.ResumeProductPoller(rt) -// if err == nil { -// t.Fatal("expected an error but did not find receive one") -// } -// } +func TestLROResumeWrongPoller(t *testing.T) { + // TODO discuss what sort of check we want with the new design to avoid resuming from the wrong poller type + op := getLROSOperations(t) + resp, err := op.BeginDelete202NoRetry204(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + diffPoller, err := op.ResumePost200WithPayload(rt) + if err == nil { + t.Fatal("expected an error but did not find receive one") + } + if diffPoller != nil { + t.Fatal("expected a nil poller from the resume operation") + } +} func TestLROBeginDelete202NoRetry204(t *testing.T) { op := getLROSOperations(t) @@ -69,1142 +75,983 @@ func TestLROBeginDelete202NoRetry204(t *testing.T) { if err != nil { t.Fatal(err) } - for !poller.Done() { - _, err := poller.Poll(context.Background()) - if err != nil { - t.Fatal(err) - } - time.Sleep(200 * time.Millisecond) - } - resp, err = poller.FinalResponse(context.Background()) + resp, err = resp.PollUntilDone(context.Background(), 1*time.Millisecond) if err != nil { t.Fatal(err) } helpers.VerifyStatusCode(t, resp.RawResponse, 204) - resp1, err := op.BeginDelete202NoRetry204(context.Background()) +} + +func TestLROBeginDelete202Retry200(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginDelete202Retry200(context.Background()) if err != nil { t.Fatal(err) } - resp, err = resp1.PollUntilDone(context.Background(), time.Duration(1)*time.Second) + poller := resp.Poller + rt, err := poller.ResumeToken() if err != nil { t.Fatal(err) } - helpers.VerifyStatusCode(t, resp.RawResponse, 204) + poller, err = op.ResumeDelete202Retry200(rt) + if err != nil { + t.Fatal(err) + } + resp, err = resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, resp.RawResponse, 200) +} + +func TestLROBeginDelete204Succeeded(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginDelete204Succeeded(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller _, err = poller.ResumeToken() if err == nil { - t.Fatal("did not receive an error but was expecting one") + t.Fatal("expected an error but did not receive one") + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) } + helpers.VerifyStatusCode(t, res, 204) } -// func TestLROBeginDelete202Retry200(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginDelete202Retry200(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSDelete202Retry200Poller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// _, err = poller.ResumeToken() -// if err == nil { -// t.Fatal("did not receive an error but was expecting one") -// } -// } - -// func TestLROBeginDelete204Succeeded(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginDelete204Succeeded(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// _, err = poller.ResumeToken() -// if err == nil { -// t.Fatal("expected an error but did not receive one") -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp, 204) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp, 204) -// _, err = poller.ResumeToken() -// if err == nil { -// t.Fatal("did not receive an error but was expecting one") -// } -// } - -// func TestLROBeginDeleteAsyncNoHeaderInRetry(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginDeleteAsyncNoHeaderInRetry(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSDeleteAsyncNoHeaderInRetryPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// _, err = poller.ResumeToken() -// if err == nil { -// t.Fatal("did not receive an error but was expecting one") -// } -// } - -// func TestLROBeginDeleteAsyncNoRetrySucceeded(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginDeleteAsyncNoRetrySucceeded(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSDeleteAsyncNoRetrySucceededPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// _, err = poller.ResumeToken() -// if err == nil { -// t.Fatal("did not receive an error but was expecting one") -// } -// } - -// func TestLROBeginDeleteAsyncRetryFailed(t *testing.T) { -// t.Skip("CloudError unmarshalling is failing") -// op := getLROSOperations(t) -// poller, err := op.BeginDeleteAsyncRetryFailed(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSDeleteAsyncRetryFailedPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } - -// func TestLROBeginDeleteAsyncRetrySucceeded(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginDeleteAsyncRetrySucceeded(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSDeleteAsyncRetrySucceededPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } - -// func TestLROBeginDeleteAsyncRetrycanceled(t *testing.T) { -// t.Skip("CloudError unmarshalling is failing") -// op := getLROSOperations(t) -// poller, err := op.BeginDeleteAsyncRetrycanceled(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSDeleteAsyncRetrycanceledPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } - -// func TestLROBeginDeleteNoHeaderInRetry(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginDeleteNoHeaderInRetry(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSDeleteNoHeaderInRetryPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 204) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 204) -// } - -// func TestLROBeginDeleteProvisioning202Accepted200Succeeded(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginDeleteProvisioning202Accepted200Succeeded(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSDeleteProvisioning202Accepted200SucceededPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } - -// func TestLROBeginDeleteProvisioning202DeletingFailed200(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginDeleteProvisioning202DeletingFailed200(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSDeleteProvisioning202DeletingFailed200Poller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// _, err = poller.Response() -// if err == nil { -// t.Fatal("expected an error but did not receive one") -// } -// _, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err == nil { -// t.Fatal("expected an error but did not receive one") -// } -// } +func TestLROBeginDeleteAsyncNoHeaderInRetry(t *testing.T) { + t.Skip("pending on CloudError field fix") + op := getLROSOperations(t) + resp, err := op.BeginDeleteAsyncNoHeaderInRetry(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumeDeleteAsyncNoHeaderInRetry(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res, 204) +} -// func TestLROBeginDeleteProvisioning202Deletingcanceled200(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginDeleteProvisioning202Deletingcanceled200(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSDeleteProvisioning202Deletingcanceled200Poller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// _, err = poller.Response() -// if err == nil { -// t.Fatal("expected an error but did not receive one") -// } -// _, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err == nil { -// t.Fatal("expected an error but did not receive one") -// } -// } +func TestLROBeginDeleteAsyncNoRetrySucceeded(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginDeleteAsyncNoRetrySucceeded(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumeDeleteAsyncNoRetrySucceeded(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res, 200) +} -// func TestLROBeginPost200WithPayload(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPost200WithPayload(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPost200WithPayloadPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginDeleteAsyncRetryFailed(t *testing.T) { + t.Skip("CloudError unmarshalling is failing") + op := getLROSOperations(t) + resp, err := op.BeginDeleteAsyncRetryFailed(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumeDeleteAsyncRetryFailed(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res, 200) +} -// func TestLROBeginPost202NoRetry204(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPost202NoRetry204(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPost202NoRetry204Poller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 204) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 204) -// } +func TestLROBeginDeleteAsyncRetrySucceeded(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginDeleteAsyncRetrySucceeded(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumeDeleteAsyncRetrySucceeded(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res, 200) +} -// func TestLROBeginPost202Retry200(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPost202Retry200(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPost202Retry200Poller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginDeleteAsyncRetrycanceled(t *testing.T) { + t.Skip("CloudError unmarshalling is failing") + op := getLROSOperations(t) + resp, err := op.BeginDeleteAsyncRetrycanceled(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumeDeleteAsyncRetrycanceled(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res, 200) +} -// func TestLROBeginPostAsyncNoRetrySucceeded(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPostAsyncNoRetrySucceeded(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPostAsyncNoRetrySucceededPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginDeleteNoHeaderInRetry(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginDeleteNoHeaderInRetry(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumeDeleteNoHeaderInRetry(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res, 204) +} -// func TestLROBeginPostAsyncRetryFailed(t *testing.T) { -// t.Skip("CloudError unmarshalling fails") -// op := getLROSOperations(t) -// poller, err := op.BeginPostAsyncRetryFailed(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPostAsyncRetryFailedPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginDeleteProvisioning202Accepted200Succeeded(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginDeleteProvisioning202Accepted200Succeeded(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumeDeleteProvisioning202Accepted200Succeeded(rt) + if err != nil { + t.Fatal(err) + } + resp, err = resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, resp.RawResponse, 200) +} -// func TestLROBeginPostAsyncRetrySucceeded(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPostAsyncRetrySucceeded(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPostAsyncRetrySucceededPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginDeleteProvisioning202DeletingFailed200(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginDeleteProvisioning202DeletingFailed200(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumeDeleteProvisioning202DeletingFailed200(rt) + if err != nil { + t.Fatal(err) + } + resp, err = resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err == nil { + t.Fatal("expected an error but did not receive one") + } +} -// func TestLROBeginPostAsyncRetrycanceled(t *testing.T) { -// t.Skip("CloudError unmarshalling failed") -// op := getLROSOperations(t) -// poller, err := op.BeginPostAsyncRetrycanceled(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPostAsyncRetrycanceledPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginDeleteProvisioning202Deletingcanceled200(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginDeleteProvisioning202Deletingcanceled200(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumeDeleteProvisioning202Deletingcanceled200(rt) + if err != nil { + t.Fatal(err) + } + resp, err = resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err == nil { + t.Fatal("expected an error but did not receive one") + } +} -// func TestLROBeginPostDoubleHeadersFinalAzureHeaderGet(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPostDoubleHeadersFinalAzureHeaderGet(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPostDoubleHeadersFinalAzureHeaderGetPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPost200WithPayload(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginPost200WithPayload(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePost200WithPayload(rt) + if err != nil { + t.Fatal(err) + } + resp, err = resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, resp.RawResponse, 200) + helpers.DeepEqualOrFatal(t, resp.Sku, &lrogroup.Sku{ + ID: to.StringPtr("1"), + Name: to.StringPtr("product"), + }) +} -// func TestLROBeginPostDoubleHeadersFinalAzureHeaderGetDefault(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPostDoubleHeadersFinalAzureHeaderGetDefault(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPostDoubleHeadersFinalAzureHeaderGetDefaultPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPost202NoRetry204(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginPost202NoRetry204(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePost202NoRetry204(rt) + if err != nil { + t.Fatal(err) + } + resp, err = resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, resp.RawResponse, 204) +} -// func TestLROBeginPostDoubleHeadersFinalLocationGet(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPostDoubleHeadersFinalLocationGet(context.Background()) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPostDoubleHeadersFinalLocationGetPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPost202Retry200(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginPost202Retry200(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePost202Retry200(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res, 200) +} -// func TestLROBeginPut200Acceptedcanceled200(t *testing.T) { -// t.Skip("missing error info returned for error") -// op := getLROSOperations(t) -// poller, err := op.BeginPut200Acceptedcanceled200(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPut200Acceptedcanceled200Poller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPostAsyncNoRetrySucceeded(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginPostAsyncNoRetrySucceeded(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePostAsyncNoRetrySucceeded(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Product, &lrogroup.Product{ + Resource: lrogroup.Resource{ + ID: to.StringPtr("100"), + Name: to.StringPtr("foo"), + }, + }) +} -// func TestLROBeginPut200Succeeded(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPut200Succeeded(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// _, err = poller.ResumeToken() -// if err == nil { -// t.Fatal("expected an error but did not receive one") -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPostAsyncRetryFailed(t *testing.T) { + t.Skip("CloudError unmarshalling fails") + op := getLROSOperations(t) + resp, err := op.BeginPostAsyncRetryFailed(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePostAsyncRetryFailed(rt) + if err != nil { + t.Fatal(err) + } + _, err = resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err == nil { + t.Fatal("expected an error but did not receive one") + } +} -// func TestLROBeginPut200SucceededNoState(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPut200SucceededNoState(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// _, err = poller.ResumeToken() -// if err == nil { -// t.Fatal("expected an error but did not receive one") -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPostAsyncRetrySucceeded(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginPostAsyncRetrySucceeded(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePostAsyncRetrySucceeded(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Product, &lrogroup.Product{ + Resource: lrogroup.Resource{ + ID: to.StringPtr("100"), + Name: to.StringPtr("foo"), + }, + }) +} -// func TestLROBeginPut200UpdatingSucceeded204(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPut200UpdatingSucceeded204(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPut200UpdatingSucceeded204Poller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPostAsyncRetrycanceled(t *testing.T) { + t.Skip("CloudError unmarshalling failed") + op := getLROSOperations(t) + resp, err := op.BeginPostAsyncRetrycanceled(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePostAsyncRetrycanceled(rt) + if err != nil { + t.Fatal(err) + } + _, err = resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err == nil { + t.Fatal("expected an error but did not receive one") + } +} -// func TestLROBeginPut201CreatingFailed200(t *testing.T) { -// t.Skip("missing error info message returned for error") -// op := getLROSOperations(t) -// poller, err := op.BeginPut201CreatingFailed200(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPut201CreatingFailed200Poller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPostDoubleHeadersFinalAzureHeaderGet(t *testing.T) { + t.Skip("need to fix poller implementation, must not do a final get on location in this case") + op := getLROSOperations(t) + resp, err := op.BeginPostDoubleHeadersFinalAzureHeaderGet(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePostDoubleHeadersFinalAzureHeaderGet(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Product, &lrogroup.Product{ + Resource: lrogroup.Resource{ + ID: to.StringPtr("100"), + Name: to.StringPtr("foo"), + }, + }) +} -// func TestLROBeginPut201CreatingSucceeded200(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPut201CreatingSucceeded200(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPut201CreatingSucceeded200Poller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPostDoubleHeadersFinalAzureHeaderGetDefault(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginPostDoubleHeadersFinalAzureHeaderGetDefault(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePostDoubleHeadersFinalAzureHeaderGetDefault(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Product, &lrogroup.Product{ + Resource: lrogroup.Resource{ + ID: to.StringPtr("100"), + Name: to.StringPtr("foo"), + }, + }) +} -// func TestLROBeginPut202Retry200(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPut202Retry200(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPut202Retry200Poller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPostDoubleHeadersFinalLocationGet(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginPostDoubleHeadersFinalLocationGet(context.Background()) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePostDoubleHeadersFinalLocationGet(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Product, &lrogroup.Product{ + Resource: lrogroup.Resource{ + ID: to.StringPtr("100"), + Name: to.StringPtr("foo"), + }, + }) +} -// func TestLROBeginPutAsyncNoHeaderInRetry(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPutAsyncNoHeaderInRetry(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPutAsyncNoHeaderInRetryPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPut200Acceptedcanceled200(t *testing.T) { + t.Skip("missing error info returned for error") + op := getLROSOperations(t) + resp, err := op.BeginPut200Acceptedcanceled200(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePut200Acceptedcanceled200(rt) + if err != nil { + t.Fatal(err) + } + _, err = resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err == nil { + t.Fatal("Expected an error but did not receive one") + } +} -// func TestLROBeginPutAsyncNoRetrySucceeded(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPutAsyncNoRetrySucceeded(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPutAsyncNoRetrySucceededPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPut200Succeeded(t *testing.T) { + t.Skip("problem with poller code") + op := getLROSOperations(t) + resp, err := op.BeginPut200Succeeded(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + _, err = poller.ResumeToken() + if err == nil { + t.Fatal("Expected an error but did not receive one") + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Product, &lrogroup.Product{ + Resource: lrogroup.Resource{ + ID: to.StringPtr("100"), + Name: to.StringPtr("foo"), + }, + }) +} -// func TestLROBeginPutAsyncNoRetrycanceled(t *testing.T) { -// t.Skip("CloudError unmarshalling failed") -// op := getLROSOperations(t) -// poller, err := op.BeginPutAsyncNoRetrycanceled(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPutAsyncNoRetrycanceledPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPut200SucceededNoState(t *testing.T) { + t.Skip("problem with the poller") + op := getLROSOperations(t) + resp, err := op.BeginPut200SucceededNoState(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + _, err = poller.ResumeToken() + if err == nil { + t.Fatal("Expected an error but did not receive one") + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Product, &lrogroup.Product{ + Resource: lrogroup.Resource{ + ID: to.StringPtr("100"), + Name: to.StringPtr("foo"), + }, + }) +} -// func TestLROBeginPutAsyncNonResource(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPutAsyncNonResource(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPutAsyncNonResourcePoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +// TODO check if this test should actually be returning a 200 or a 204 +func TestLROBeginPut200UpdatingSucceeded204(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginPut200UpdatingSucceeded204(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePut200UpdatingSucceeded204(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Product, &lrogroup.Product{ + Resource: lrogroup.Resource{ + ID: to.StringPtr("100"), + Name: to.StringPtr("foo"), + }, + Properties: &lrogroup.ProductProperties{ + ProvisioningState: to.StringPtr("Succeeded"), + }, + }) +} -// func TestLROBeginPutAsyncRetryFailed(t *testing.T) { -// t.Skip("CloudError unmarshalling failed") -// op := getLROSOperations(t) -// poller, err := op.BeginPutAsyncRetryFailed(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPutAsyncRetryFailedPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPut201CreatingFailed200(t *testing.T) { + t.Skip("missing error info message returned for error") + op := getLROSOperations(t) + resp, err := op.BeginPut201CreatingFailed200(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePut201CreatingFailed200(rt) + if err != nil { + t.Fatal(err) + } + _, err = resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err == nil { + t.Fatal("expected an error but did not receive one") + } +} -// func TestLROBeginPutAsyncRetrySucceeded(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPutAsyncRetrySucceeded(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPutAsyncRetrySucceededPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPut201CreatingSucceeded200(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginPut201CreatingSucceeded200(context.Background(), &lrogroup.LrOSPut201CreatingSucceeded200Options{Product: &lrogroup.Product{}}) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePut201CreatingSucceeded200(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Product, &lrogroup.Product{ + Resource: lrogroup.Resource{ + ID: to.StringPtr("100"), + Name: to.StringPtr("foo"), + }, + Properties: &lrogroup.ProductProperties{ + ProvisioningState: to.StringPtr("Succeeded"), + }, + }) +} -// func TestLROBeginPutAsyncSubResource(t *testing.T) { -// op := getLROSOperations(t) -// poller, err := op.BeginPutAsyncSubResource(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPutAsyncSubResourcePoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPut202Retry200(t *testing.T) { + t.Skip("problem with the poller") + op := getLROSOperations(t) + resp, err := op.BeginPut202Retry200(context.Background(), &lrogroup.LrOSPut202Retry200Options{Product: &lrogroup.Product{}}) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePut202Retry200(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Product, &lrogroup.Product{ + Resource: lrogroup.Resource{ + ID: to.StringPtr("100"), + Name: to.StringPtr("foo"), + }, + Properties: &lrogroup.ProductProperties{ + ProvisioningState: to.StringPtr("Succeeded"), + }, + }) +} -// func TestLROBeginPutNoHeaderInRetry(t *testing.T) { -// t.Skip("The test needs to fix some underlying problems with the poller returning an error") -// op := getLROSOperations(t) -// poller, err := op.BeginPutNoHeaderInRetry(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPutNoHeaderInRetryPoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 202) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPutAsyncNoHeaderInRetry(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginPutAsyncNoHeaderInRetry(context.Background(), &lrogroup.LrOSPutAsyncNoHeaderInRetryOptions{Product: &lrogroup.Product{}}) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePutAsyncNoHeaderInRetry(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Product, &lrogroup.Product{ + Resource: lrogroup.Resource{ + ID: to.StringPtr("100"), + Name: to.StringPtr("foo"), + }, + Properties: &lrogroup.ProductProperties{ + ProvisioningState: to.StringPtr("Succeeded"), + }, + }) +} -// func TestLROBeginPutNonResource(t *testing.T) { -// t.Skip("The test needs to fix some underlying problems with the poller returning an error") -// op := getLROSOperations(t) -// poller, err := op.BeginPutNonResource(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPutNonResourcePoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 202) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPutAsyncNoRetrySucceeded(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginPutAsyncNoRetrySucceeded(context.Background(), &lrogroup.LrOSPutAsyncNoRetrySucceededOptions{Product: &lrogroup.Product{}}) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePutAsyncNoRetrySucceeded(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Product, &lrogroup.Product{ + Resource: lrogroup.Resource{ + ID: to.StringPtr("100"), + Name: to.StringPtr("foo"), + }, + Properties: &lrogroup.ProductProperties{ + ProvisioningState: to.StringPtr("Succeeded"), + }, + }) +} + +func TestLROBeginPutAsyncNoRetrycanceled(t *testing.T) { + t.Skip("CloudError unmarshalling failed") + op := getLROSOperations(t) + resp, err := op.BeginPutAsyncNoRetrycanceled(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePutAsyncNoRetrycanceled(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err == nil { + t.Fatal("expected an error but did not receive one") + } + if res != nil { + t.Fatal("expected a nil response with the error") + } + // var cloudErr lrogroup.CloudError + // if !errors.As(err, &cloudErr) { + // t.Fatal("expected a CloudError but did not receive one") + // } else { + // helpers.DeepEqualOrFatal(t, cloudErr, lrogroup.CloudError{}) + // } +} -// func TestLROBeginPutSubResource(t *testing.T) { -// t.Skip("The test needs to fix some underlying problems with the poller returning an error") -// op := getLROSOperations(t) -// poller, err := op.BeginPutSubResource(context.Background(), nil) -// if err != nil { -// t.Fatal(err) -// } -// rt, err := poller.ResumeToken() -// if err != nil { -// t.Fatal(err) -// } -// poller, err = op.ResumeLrOSPutSubResourcePoller(rt) -// if err != nil { -// t.Fatal(err) -// } -// for poller.Poll(context.Background()) { -// time.Sleep(200 * time.Millisecond) -// } -// resp, err := poller.Response() -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 202) -// resp, err = poller.Wait(context.Background(), time.Duration(1)*time.Second) -// if err != nil { -// t.Fatal(err) -// } -// helpers.VerifyStatusCode(t, resp.RawResponse, 200) -// } +func TestLROBeginPutAsyncNonResource(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginPutAsyncNonResource(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePutAsyncNonResource(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Sku, &lrogroup.Sku{ + ID: to.StringPtr("100"), + Name: to.StringPtr("sku"), + }) +} + +func TestLROBeginPutAsyncRetryFailed(t *testing.T) { + t.Skip("CloudError unmarshalling failed") + op := getLROSOperations(t) + resp, err := op.BeginPutAsyncRetryFailed(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePutAsyncRetryFailed(rt) + if err != nil { + t.Fatal(err) + } + _, err = resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err == nil { + t.Fatal("expected an error but did not receive one") + } +} + +func TestLROBeginPutAsyncRetrySucceeded(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginPutAsyncRetrySucceeded(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePutAsyncRetrySucceeded(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Product, &lrogroup.Product{ + Resource: lrogroup.Resource{ + ID: to.StringPtr("100"), + Name: to.StringPtr("foo"), + }, + Properties: &lrogroup.ProductProperties{ + ProvisioningState: to.StringPtr("Succeeded"), + }, + }) +} + +func TestLROBeginPutAsyncSubResource(t *testing.T) { + op := getLROSOperations(t) + resp, err := op.BeginPutAsyncSubResource(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePutAsyncSubResource(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.SubProduct, &lrogroup.SubProduct{ + SubResource: lrogroup.SubResource{ + ID: to.StringPtr("100"), + }, + Properties: &lrogroup.SubProductProperties{ + ProvisioningState: to.StringPtr("Succeeded"), + }, + }) +} + +func TestLROBeginPutNoHeaderInRetry(t *testing.T) { + t.Skip("problem with the poller") + op := getLROSOperations(t) + resp, err := op.BeginPutNoHeaderInRetry(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePutNoHeaderInRetry(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Product, &lrogroup.Product{ + Resource: lrogroup.Resource{ + ID: to.StringPtr("100"), + }, + Properties: &lrogroup.ProductProperties{ + ProvisioningState: to.StringPtr("Succeeded"), + }, + }) +} + +func TestLROBeginPutNonResource(t *testing.T) { + t.Skip("The test needs to fix some underlying problems with the poller returning an error") + op := getLROSOperations(t) + resp, err := op.BeginPutNonResource(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePutNonResource(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.Sku, &lrogroup.Sku{ + ID: to.StringPtr("100"), + Name: to.StringPtr("sku"), + }) +} + +func TestLROBeginPutSubResource(t *testing.T) { + t.Skip("The test needs to fix some underlying problems with the poller returning an error") + op := getLROSOperations(t) + resp, err := op.BeginPutSubResource(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + poller := resp.Poller + rt, err := poller.ResumeToken() + if err != nil { + t.Fatal(err) + } + poller, err = op.ResumePutSubResource(rt) + if err != nil { + t.Fatal(err) + } + res, err := resp.PollUntilDone(context.Background(), 1*time.Millisecond) + if err != nil { + t.Fatal(err) + } + helpers.VerifyStatusCode(t, res.RawResponse, 200) + helpers.DeepEqualOrFatal(t, res.SubProduct, &lrogroup.SubProduct{ + SubResource: lrogroup.SubResource{ + ID: to.StringPtr("100"), + }, + Properties: &lrogroup.SubProductProperties{ + ProvisioningState: to.StringPtr("Succeeded"), + }, + }) +}