Merge pull request #44182 from thaJeztah/subtests_TestNewClientWithOpsFromEnv
client: TestNewClientWithOpsFromEnv(): use sub-tests
This commit is contained in:
commit
2a7908c939
1 changed files with 18 additions and 15 deletions
|
@ -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))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue