Merge branch 'main' into 18324-lsf-gpu
[arvados.git] / sdk / go / arvados / client_test.go
index b0627fd27a665bf26250892c3fabd3319ff4e489..df938008d49756b850ca6e5ce5abee8a0510e2a3 100644 (file)
@@ -12,6 +12,7 @@ import (
        "net/url"
        "sync"
        "testing"
+       "testing/iotest"
 )
 
 type stubTransport struct {
@@ -51,6 +52,22 @@ func (stub *errorTransport) RoundTrip(req *http.Request) (*http.Response, error)
        return nil, fmt.Errorf("something awful happened")
 }
 
+type timeoutTransport struct {
+       response []byte
+}
+
+func (stub *timeoutTransport) RoundTrip(req *http.Request) (*http.Response, error) {
+       return &http.Response{
+               Status:     "200 OK",
+               StatusCode: 200,
+               Proto:      "HTTP/1.1",
+               ProtoMajor: 1,
+               ProtoMinor: 1,
+               Request:    req,
+               Body:       ioutil.NopCloser(iotest.TimeoutReader(bytes.NewReader(stub.response))),
+       }, nil
+}
+
 func TestCurrentUser(t *testing.T) {
        t.Parallel()
        stub := &stubTransport{