summaryrefslogtreecommitdiff
path: root/client/client_mock_test.go
diff options
context:
space:
mode:
authorStephen J Day <stephen.day@docker.com>2016-09-08 20:44:25 -0700
committerStephen J Day <stephen.day@docker.com>2016-09-19 11:19:55 -0700
commit9a072adff3fcd90c4f36214b355ef27b423f0144 (patch)
tree6446b5142faf77cfdd5af70093ed450b2f78bdf6 /client/client_mock_test.go
parent9d7be9df8f79b26a4b9778851cf19a6579f8bc61 (diff)
downloaddocker-9a072adff3fcd90c4f36214b355ef27b423f0144.tar.gz
client: remove transport package
This package doesn't really seem to do anything of real interest. Removing it and replacing with a few helper functions. Most of this was maintaining a fork of ctxhttp to support a mock that was unnecessary. We could probably do with a further refactor of the client interface. There is a lot of confusion of between transport, http layer and application layer that makes for some awkward code. This change improves the situation to the point where no breaking changes are introduced. Signed-off-by: Stephen J Day <stephen.day@docker.com>
Diffstat (limited to 'client/client_mock_test.go')
-rw-r--r--client/client_mock_test.go37
1 files changed, 3 insertions, 34 deletions
diff --git a/client/client_mock_test.go b/client/client_mock_test.go
index 33c247266c..0ab935d536 100644
--- a/client/client_mock_test.go
+++ b/client/client_mock_test.go
@@ -2,50 +2,19 @@ package client
import (
"bytes"
- "crypto/tls"
"encoding/json"
"io/ioutil"
"net/http"
"github.com/docker/docker/api/types"
- "github.com/docker/docker/client/transport"
)
-type mockClient struct {
- do func(*http.Request) (*http.Response, error)
-}
-
-// TLSConfig returns the TLS configuration.
-func (m *mockClient) TLSConfig() *tls.Config {
- return &tls.Config{}
-}
-
-// Scheme returns protocol scheme to use.
-func (m *mockClient) Scheme() string {
- return "http"
-}
-
-// Secure returns true if there is a TLS configuration.
-func (m *mockClient) Secure() bool {
- return false
-}
-
-// NewMockClient returns a mocked client that runs the function supplied as `client.Do` call
-func newMockClient(tlsConfig *tls.Config, doer func(*http.Request) (*http.Response, error)) transport.Client {
- if tlsConfig != nil {
- panic("this actually gets set!")
- }
-
- return &mockClient{
- do: doer,
+func newMockClient(doer func(*http.Request) (*http.Response, error)) *http.Client {
+ return &http.Client{
+ Transport: transportFunc(doer),
}
}
-// Do executes the supplied function for the mock.
-func (m mockClient) Do(req *http.Request) (*http.Response, error) {
- return m.do(req)
-}
-
func errorMock(statusCode int, message string) func(req *http.Request) (*http.Response, error) {
return func(req *http.Request) (*http.Response, error) {
header := http.Header{}