1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
package client
import (
"net/http"
"testing"
"time"
"github.com/aws/aws-sdk-go/aws/request"
)
func TestNoOpRetryer(t *testing.T) {
cases := []struct {
r request.Request
expectMaxRetries int
expectRetryDelay time.Duration
expectRetry bool
}{
{
r: request.Request{
HTTPResponse: &http.Response{StatusCode: 200},
},
expectMaxRetries: 0,
expectRetryDelay: 0,
expectRetry: false,
},
}
d := NoOpRetryer{}
for i, c := range cases {
maxRetries := d.MaxRetries()
retry := d.ShouldRetry(&c.r)
retryDelay := d.RetryRules(&c.r)
if e, a := c.expectMaxRetries, maxRetries; e != a {
t.Errorf("%d: expected %v, but received %v for number of max retries", i, e, a)
}
if e, a := c.expectRetry, retry; e != a {
t.Errorf("%d: expected %v, but received %v for should retry", i, e, a)
}
if e, a := c.expectRetryDelay, retryDelay; e != a {
t.Errorf("%d: expected %v, but received %v as retry delay", i, e, a)
}
}
}
|