Merge branch 'master' into 13822-nm-delayed-daemon
[arvados.git] / sdk / go / arvados / client_test.go
index 5011aa81f689c0bf1d6098c123bcaeee14ba6c41..df938008d49756b850ca6e5ce5abee8a0510e2a3 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
 package arvados
 
 import (
@@ -8,6 +12,7 @@ import (
        "net/url"
        "sync"
        "testing"
+       "testing/iotest"
 )
 
 type stubTransport struct {
@@ -47,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{