- increase mock handler processing time to 50ms to try to prevent it from finishing before the 10ms client timeout occurs
- replace deprecated error type assertion
Signed-off-by: Adam Simon <adamsimon85100@gmail.com>
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
"net/http" |
| 10 | 10 |
"net/http/httptest" |
| 11 | 11 |
"net/url" |
| 12 |
- "os" |
|
| 13 | 12 |
"strings" |
| 14 | 13 |
"testing" |
| 15 | 14 |
"time" |
| ... | ... |
@@ -169,15 +168,21 @@ func TestNewClientWithTimeout(t *testing.T) {
|
| 169 | 169 |
m := Manifest{[]string{"VolumeDriver", "NetworkDriver"}}
|
| 170 | 170 |
|
| 171 | 171 |
mux.HandleFunc("/Test.Echo", func(w http.ResponseWriter, r *http.Request) {
|
| 172 |
- time.Sleep(20 * time.Millisecond) |
|
| 172 |
+ time.Sleep(50 * time.Millisecond) |
|
| 173 | 173 |
io.Copy(w, r.Body) |
| 174 | 174 |
}) |
| 175 | 175 |
|
| 176 | 176 |
timeout := 10 * time.Millisecond |
| 177 | 177 |
c, _ := NewClientWithTimeout(addr, &tlsconfig.Options{InsecureSkipVerify: true}, timeout)
|
| 178 | 178 |
var output Manifest |
| 179 |
+ |
|
| 179 | 180 |
err := c.CallWithOptions("Test.Echo", m, &output, func(opts *RequestOpts) { opts.testTimeOut = 1 })
|
| 180 |
- assert.ErrorType(t, err, os.IsTimeout) |
|
| 181 |
+ var tErr interface {
|
|
| 182 |
+ Timeout() bool |
|
| 183 |
+ } |
|
| 184 |
+ if assert.Check(t, errors.As(err, &tErr), "want timeout error, got %T", err) {
|
|
| 185 |
+ assert.Check(t, tErr.Timeout()) |
|
| 186 |
+ } |
|
| 181 | 187 |
} |
| 182 | 188 |
|
| 183 | 189 |
func TestClientStream(t *testing.T) {
|