@@ -304,85 +304,86 @@ func TestPollerLRO_InStatus_AcceptedThenInProgressThenSuccess(t *testing.T) {
304
304
helpers .assertCalled (t , 3 )
305
305
}
306
306
307
- //func TestPollerLRO_InProvisioningState_AcceptedThenDroppedThenInProgressThenSuccess(t *testing.T) {
308
- // ctx := context.TODO()
309
- // helpers := newLongRunningOperationsEndpoint([]expectedResponse{
310
- // responseWithHttpStatusCode(http.StatusAccepted),
311
- // responseThatDropsTheConnection(),
312
- // responseWithStatusInProvisioningState(statusInProgress),
313
- // responseWithStatusInProvisioningState(statusSucceeded),
314
- // })
315
- // server := httptest.NewServer(http.HandlerFunc(helpers.endpoint(t)))
316
- // defer server.Close()
317
- //
318
- // response := &client.Response{
319
- // Response: helpers.response(),
320
- // }
321
- // client := client.NewClient(server.URL, "MyService", "2020-02-01")
322
- // poller, err := longRunningOperationPollerFromResponse(response, client)
323
- // if err != nil {
324
- // t.Fatal(err.Error())
325
- // }
326
- //
327
- // expectedStatuses := []pollers.PollingStatus{
328
- // pollers.PollingStatusInProgress, // the 202 Accepted
329
- // // NOTE: the Dropped Connection will be ignored/silently retried
330
- // pollers.PollingStatusInProgress, // working on it
331
- // pollers.PollingStatusSucceeded, // good
332
- // }
333
- // for i, expected := range expectedStatuses {
334
- // t.Logf("Poll %d..", i)
335
- // result, err := poller.Poll(ctx)
336
- // if err != nil {
337
- // t.Fatal(err.Error())
338
- // }
339
- // if result.Status != expected {
340
- // t.Fatalf("expected status to be %q but got %q", expected, result.Status)
341
- // }
342
- // }
343
- // // sanity-checking - expect 4 calls but 3 statuses (since the dropped connection is silently retried)
344
- // helpers.assertCalled(t, 4)
345
- //}
346
-
347
- //func TestPollerLRO_InStatus_AcceptedThenDroppedThenInProgressThenSuccess(t *testing.T) {
348
- // ctx := context.TODO()
349
- // helpers := newLongRunningOperationsEndpoint([]expectedResponse{
350
- // responseWithHttpStatusCode(http.StatusAccepted),
351
- // responseThatDropsTheConnection(),
352
- // responseWithStatusInStatusField(statusInProgress),
353
- // responseWithStatusInStatusField(statusSucceeded),
354
- // })
355
- // server := httptest.NewServer(http.HandlerFunc(helpers.endpoint(t)))
356
- // defer server.Close()
357
- //
358
- // response := &client.Response{
359
- // Response: helpers.response(),
360
- // }
361
- // client := client.NewClient(server.URL, "MyService", "2020-02-01")
362
- // poller, err := longRunningOperationPollerFromResponse(response, client)
363
- // if err != nil {
364
- // t.Fatal(err.Error())
365
- // }
366
- //
367
- // expectedStatuses := []pollers.PollingStatus{
368
- // pollers.PollingStatusInProgress, // the 202 Accepted
369
- // // NOTE: the Dropped Connection will be ignored/silently retried
370
- // pollers.PollingStatusInProgress, // working on it
371
- // pollers.PollingStatusSucceeded, // good
372
- // }
373
- // for i, expected := range expectedStatuses {
374
- // t.Logf("Poll %d..", i)
375
- // result, err := poller.Poll(ctx)
376
- // if err != nil {
377
- // t.Fatal(err.Error())
378
- // }
379
- // if result.Status != expected {
380
- // t.Fatalf("expected status to be %q but got %q", expected, result.Status)
381
- // }
382
- // }
383
- // // sanity-checking - expect 4 calls but 3 statuses (since the dropped connection is silently retried)
384
- // helpers.assertCalled(t, 4)
385
- //}
307
+ func TestPollerLRO_InProvisioningState_AcceptedThenDroppedThenInProgressThenSuccess (t * testing.T ) {
308
+ ctx := context .TODO ()
309
+ helpers := newLongRunningOperationsEndpoint ([]expectedResponse {
310
+ responseWithHttpStatusCode (http .StatusAccepted ),
311
+ responseThatDropsTheConnection (),
312
+ responseWithStatusInProvisioningState (statusInProgress ),
313
+ responseWithStatusInProvisioningState (statusSucceeded ),
314
+ })
315
+ server := httptest .NewServer (http .HandlerFunc (helpers .endpoint (t )))
316
+ defer server .Close ()
317
+
318
+ response := & client.Response {
319
+ Response : helpers .response (),
320
+ }
321
+ client := client .NewClient (server .URL , "MyService" , "2020-02-01" )
322
+ poller , err := longRunningOperationPollerFromResponse (response , client )
323
+ if err != nil {
324
+ t .Fatal (err .Error ())
325
+ }
326
+
327
+ expectedStatuses := []pollers.PollingStatus {
328
+ pollers .PollingStatusInProgress , // the 202 Accepted
329
+ pollers .PollingStatusUnknown ,
330
+ // NOTE: the Dropped Connection will be ignored/silently retried
331
+ pollers .PollingStatusInProgress , // working on it
332
+ pollers .PollingStatusSucceeded , // good
333
+ }
334
+ for i , expected := range expectedStatuses {
335
+ t .Logf ("Poll %d.." , i )
336
+ result , err := poller .Poll (ctx )
337
+ if err != nil {
338
+ t .Fatal (err .Error ())
339
+ }
340
+ if result .Status != expected {
341
+ t .Fatalf ("expected status to be %q but got %q" , expected , result .Status )
342
+ }
343
+ }
344
+ // sanity-checking - expect 4 calls but 3 statuses (since the dropped connection is silently retried)
345
+ helpers .assertCalled (t , 4 )
346
+ }
347
+
348
+ func TestPollerLRO_InStatus_AcceptedThenDroppedThenInProgressThenSuccess (t * testing.T ) {
349
+ ctx := context .TODO ()
350
+ helpers := newLongRunningOperationsEndpoint ([]expectedResponse {
351
+ responseWithHttpStatusCode (http .StatusAccepted ),
352
+ responseThatDropsTheConnection (),
353
+ responseWithStatusInStatusField (statusInProgress ),
354
+ responseWithStatusInStatusField (statusSucceeded ),
355
+ })
356
+ server := httptest .NewServer (http .HandlerFunc (helpers .endpoint (t )))
357
+ defer server .Close ()
358
+
359
+ response := & client.Response {
360
+ Response : helpers .response (),
361
+ }
362
+ client := client .NewClient (server .URL , "MyService" , "2020-02-01" )
363
+ poller , err := longRunningOperationPollerFromResponse (response , client )
364
+ if err != nil {
365
+ t .Fatal (err .Error ())
366
+ }
367
+
368
+ expectedStatuses := []pollers.PollingStatus {
369
+ pollers .PollingStatusInProgress , // the 202 Accepted
370
+ pollers .PollingStatusUnknown ,
371
+ pollers .PollingStatusInProgress , // working on it
372
+ pollers .PollingStatusSucceeded , // good
373
+ }
374
+ for i , expected := range expectedStatuses {
375
+ t .Logf ("Poll %d.." , i )
376
+ result , err := poller .Poll (ctx )
377
+ if err != nil {
378
+ t .Fatal (err .Error ())
379
+ }
380
+ if result .Status != expected {
381
+ t .Fatalf ("expected status to be %q but got %q" , expected , result .Status )
382
+ }
383
+ }
384
+ // sanity-checking - expect 4 calls but 3 statuses (since the dropped connection is silently retried)
385
+ helpers .assertCalled (t , 4 )
386
+ }
386
387
387
388
func TestPollerLRO_InProvisioningState_404ThenImmediateSuccess (t * testing.T ) {
388
389
// This scenario handles the API returning a 404 initially, then succeeded
0 commit comments