Skip to content

Commit

Permalink
fixing a broken reference
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Sep 7, 2018
1 parent 391c25f commit a844567
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
15 changes: 5 additions & 10 deletions autorest/azure/async_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,10 +793,9 @@ func TestFuture_WaitForCompletion(t *testing.T) {
sender := mocks.NewSender()
sender.AppendAndRepeatResponse(r2, 2)
sender.AppendResponse(r3)
pollingDuration := autorest.DefaultPollingDuration
client := autorest.Client{
PollingDelay: 1 * time.Second,
PollingDuration: &pollingDuration,
PollingDuration: autorest.DefaultPollingDuration,
RetryAttempts: autorest.DefaultRetryAttempts,
RetryDuration: 1 * time.Second,
Sender: sender,
Expand Down Expand Up @@ -827,10 +826,9 @@ func TestFuture_WaitForCompletionRef(t *testing.T) {
sender := mocks.NewSender()
sender.AppendAndRepeatResponse(r2, 2)
sender.AppendResponse(r3)
pollingDuration := autorest.DefaultPollingDuration
client := autorest.Client{
PollingDelay: 1 * time.Second,
PollingDuration: &pollingDuration,
PollingDuration: autorest.DefaultPollingDuration,
RetryAttempts: autorest.DefaultRetryAttempts,
RetryDuration: 1 * time.Second,
Sender: sender,
Expand Down Expand Up @@ -865,10 +863,9 @@ func TestFuture_WaitForCompletionTimedOut(t *testing.T) {
t.Fatalf("failed to create future: %v", err)
}

pollingDuration := 2 * time.Second
client := autorest.Client{
PollingDelay: autorest.DefaultPollingDelay,
PollingDuration: &pollingDuration,
PollingDuration: 2 * time.Second,
RetryAttempts: autorest.DefaultRetryAttempts,
RetryDuration: 1 * time.Second,
Sender: sender,
Expand All @@ -892,10 +889,9 @@ func TestFuture_WaitForCompletionRetriesExceeded(t *testing.T) {
t.Fatalf("failed to create future: %v", err)
}

pollingDuration := autorest.DefaultPollingDuration
client := autorest.Client{
PollingDelay: autorest.DefaultPollingDelay,
PollingDuration: &pollingDuration,
PollingDuration: autorest.DefaultPollingDuration,
RetryAttempts: autorest.DefaultRetryAttempts,
RetryDuration: 100 * time.Millisecond,
Sender: sender,
Expand All @@ -918,10 +914,9 @@ func TestFuture_WaitForCompletionCancelled(t *testing.T) {
t.Fatalf("failed to create future: %v", err)
}

pollingDuration := autorest.DefaultPollingDuration
client := autorest.Client{
PollingDelay: autorest.DefaultPollingDelay,
PollingDuration: &pollingDuration,
PollingDuration: autorest.DefaultPollingDuration,
RetryAttempts: autorest.DefaultRetryAttempts,
RetryDuration: autorest.DefaultRetryDuration,
Sender: sender,
Expand Down
4 changes: 2 additions & 2 deletions autorest/azure/rp.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func register(client autorest.Client, originalReq *http.Request, re RequestError

// poll for registered provisioning state
registrationStartTime := time.Now()
for err == nil && (client.PollingDuration == nil || (client.PollingDuration != nil && time.Since(registrationStartTime) < *client.PollingDuration)) {
for err == nil && (client.PollingDuration == 0 || (client.PollingDuration != 0 && time.Since(registrationStartTime) < client.PollingDuration)) {
// taken from the resources SDK
// https://github.com/Azure/azure-sdk-for-go/blob/9f366792afa3e0ddaecdc860e793ba9d75e76c27/arm/resources/resources/providers.go#L45
preparer := autorest.CreatePreparer(
Expand Down Expand Up @@ -183,7 +183,7 @@ func register(client autorest.Client, originalReq *http.Request, re RequestError
return originalReq.Context().Err()
}
}
if client.PollingDuration != nil && !(time.Since(registrationStartTime) < *client.PollingDuration) {
if client.PollingDuration != 0 && !(time.Since(registrationStartTime) < client.PollingDuration) {
return errors.New("polling for resource provider registration has exceeded the polling duration")
}
return err
Expand Down
8 changes: 3 additions & 5 deletions autorest/azure/rp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ func TestDoRetryWithRegistration(t *testing.T) {

req := mocks.NewRequestForURL("https://lol/subscriptions/rofl")
req.Body = mocks.NewBody("lolol")
pollingDuration := time.Second * 10
r, err := autorest.SendWithSender(client, req,
DoRetryWithRegistration(autorest.Client{
PollingDelay: time.Second,
PollingDuration: &pollingDuration,
PollingDuration: time.Second * 10,
RetryAttempts: 5,
RetryDuration: time.Second,
Sender: client,
Expand Down Expand Up @@ -104,11 +103,10 @@ func TestDoRetrySkipRegistration(t *testing.T) {

req := mocks.NewRequestForURL("https://lol/subscriptions/rofl")
req.Body = mocks.NewBody("lolol")
pollingDuration := time.Second * 10
r, err := autorest.SendWithSender(client, req,
DoRetryWithRegistration(autorest.Client{
PollingDelay: time.Second,
PollingDuration: &pollingDuration,
PollingDuration: time.Second * 10,
RetryAttempts: 5,
RetryDuration: time.Second,
Sender: client,
Expand Down Expand Up @@ -149,7 +147,7 @@ func TestDoRetryWithRegistration_CanBeCancelled(t *testing.T) {
_, err = autorest.SendWithSender(client, req,
DoRetryWithRegistration(autorest.Client{
PollingDelay: time.Second,
PollingDuration: &delay,
PollingDuration: delay,
RetryAttempts: 5,
RetryDuration: time.Second,
Sender: client,
Expand Down
3 changes: 1 addition & 2 deletions autorest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,9 @@ type Client struct {
// NewClientWithUserAgent returns an instance of a Client with the UserAgent set to the passed
// string.
func NewClientWithUserAgent(ua string) Client {
pollingDuration := DefaultPollingDuration
c := Client{
PollingDelay: DefaultPollingDelay,
PollingDuration: &pollingDuration,
PollingDuration: DefaultPollingDuration,
RetryAttempts: DefaultRetryAttempts,
RetryDuration: DefaultRetryDuration,
UserAgent: defaultUserAgent,
Expand Down

0 comments on commit a844567

Please sign in to comment.