diff options
author | Sebastiaan van Stijn <thaJeztah@users.noreply.github.com> | 2022-12-27 13:12:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-27 13:12:50 +0100 |
commit | 2a7908c9399f1f6c5e1c640b74ed684204e384e0 (patch) | |
tree | 0d606f44901056ce10d84a56f91a93e784ff325f | |
parent | c4ed09ad4ef58783f7aadad9e91c4a9401be2620 (diff) | |
parent | 0af7b4961a28710eea0e1fa3a0f5c66ed7090651 (diff) | |
download | docker-2a7908c9399f1f6c5e1c640b74ed684204e384e0.tar.gz |
Merge pull request #44182 from thaJeztah/subtests_TestNewClientWithOpsFromEnv
client: TestNewClientWithOpsFromEnv(): use sub-tests
-rw-r--r-- | client/client_test.go | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/client/client_test.go b/client/client_test.go index 10cf2d2f45..bb31ff069e 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -85,23 +85,26 @@ func TestNewClientWithOpsFromEnv(t *testing.T) { }, } - defer env.PatchAll(t, nil)() + env.PatchAll(t, nil) for _, tc := range testcases { - env.PatchAll(t, tc.envs) - client, err := NewClientWithOpts(FromEnv) - if tc.expectedError != "" { - assert.Check(t, is.Error(err, tc.expectedError), tc.doc) - } else { - assert.Check(t, err, tc.doc) - assert.Check(t, is.Equal(client.ClientVersion(), tc.expectedVersion), tc.doc) - } + tc := tc + t.Run(tc.doc, func(t *testing.T) { + env.PatchAll(t, tc.envs) + client, err := NewClientWithOpts(FromEnv) + if tc.expectedError != "" { + assert.Check(t, is.Error(err, tc.expectedError)) + } else { + assert.Check(t, err) + assert.Check(t, is.Equal(client.ClientVersion(), tc.expectedVersion)) + } - if tc.envs["DOCKER_TLS_VERIFY"] != "" { - // pedantic checking that this is handled correctly - tr := client.client.Transport.(*http.Transport) - assert.Assert(t, tr.TLSClientConfig != nil, tc.doc) - assert.Check(t, is.Equal(tr.TLSClientConfig.InsecureSkipVerify, false), tc.doc) - } + if tc.envs["DOCKER_TLS_VERIFY"] != "" { + // pedantic checking that this is handled correctly + tr := client.client.Transport.(*http.Transport) + assert.Assert(t, tr.TLSClientConfig != nil) + assert.Check(t, is.Equal(tr.TLSClientConfig.InsecureSkipVerify, false)) + } + }) } } |