"net"
"net/http"
"os"
- "strings"
"testing"
"time"
)
{
"get", 0, 401, []int{500, 401, 200}, []string{``, ``, `{"ok":"ok"}`},
},
- // Use expected = 0 to simulate error during request processing
+ // Use nil responseBody to simulate error during request processing
// Even though retryable, the simulated error applies during reties also, and hence "get" also eventually fails in this test.
{
- "get", 0, 0, []int{500, 500, 500}, []string{``, ``, ``},
+ "get", 0, -1, nil, nil,
},
{
- "create", 0, 0, []int{500, 500, 500}, []string{``, ``, ``},
+ "create", 0, -1, nil, nil,
},
} {
api, err := RunFakeArvadosServer(&stub)
Client: &http.Client{Transport: &http.Transport{}},
Retries: 2}
- // We use expected = 0 to look for errors during request processing
+ // We use nil responseBody to look for errors during request processing
// Simulate an error using https (but the arv.Client transport used does not support it)
- if stub.expected == 0 {
+ if stub.responseBody == nil {
arv.Scheme = "https"
}
} else {
c.Check(err, NotNil)
- if stub.expected == 0 { // test uses 0 to look for errors during request processing
- c.Check(strings.Contains(err.Error(), fmt.Sprintf("%s", "tls: oversized record received")), Equals, true)
+ if stub.responseBody == nil { // test uses empty responseBody to look for errors during request processing
+ c.Assert(err, ErrorMatches, "* oversized record received.*")
} else {
- c.Check(strings.Contains(err.Error(), fmt.Sprintf("%s%d", "arvados API server error: ", stub.expected)), Equals, true)
+ c.Assert(err, ErrorMatches, fmt.Sprintf("%s%d.*", "arvados API server error: ", stub.expected))
c.Assert(err.(APIServerError).HttpStatusCode, Equals, stub.expected)
}
}