10BC0 client/client_test: Use functional option to create mock client · moby/moby@6452807 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6452807

Browse files
committed
client/client_test: Use functional option to create mock client
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
1 parent a3d073e commit 6452807

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

client/client_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,16 @@ func TestNegotiateAPIVersionConnectionFailure(t *testing.T) {
360360

361361
func TestNegotiateAPIVersionAutomatic(t *testing.T) {
362362
var pingVersion string
363-
httpClient := newMockClient(func(req *http.Request) (*http.Response, error) {
364-
resp := &http.Response{StatusCode: http.StatusOK, Header: http.Header{}}
365-
resp.Header.Set("Api-Version", pingVersion)
366-
resp.Body = io.NopCloser(strings.NewReader("OK"))
367-
return resp, nil
368-
})
369363

370364
ctx := context.Background()
371365
client, err := NewClientWithOpts(
372-
WithHTTPClient(httpClient),
366+
WithHTTPClient(&http.Client{
367+
Transport: roundTripFunc(func(req *http.Request) (*http.Response, error) {
368+
resp := &http.Response{StatusCode: http.StatusOK, Header: http.Header{}}
369+
resp.Header.Set("Api-Version", pingVersion)
370+
resp.Body = io.NopCloser(strings.NewReader("OK"))
371+
return resp, nil
372+
})}),
373373
WithAPIVersionNegotiation(),
374374
)
375375
assert.NilError(t, err)

0 commit comments

Comments
 (0)
0