replace deprecated gotest.tools' env.Patch() with t.SetEnv()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c93bffa1b2
commit
a5f6500958
4 changed files with 22 additions and 26 deletions
|
@ -174,12 +174,12 @@ func TestParseHostURL(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestNewClientWithOpsFromEnvSetsDefaultVersion(t *testing.T) {
|
||||
defer env.PatchAll(t, map[string]string{
|
||||
env.PatchAll(t, map[string]string{
|
||||
"DOCKER_HOST": "",
|
||||
"DOCKER_API_VERSION": "",
|
||||
"DOCKER_TLS_VERIFY": "",
|
||||
"DOCKER_CERT_PATH": "",
|
||||
})()
|
||||
})
|
||||
|
||||
client, err := NewClientWithOpts(FromEnv)
|
||||
if err != nil {
|
||||
|
@ -200,7 +200,7 @@ func TestNewClientWithOpsFromEnvSetsDefaultVersion(t *testing.T) {
|
|||
// downgrades to the correct API version if the API's ping response does not
|
||||
// return an API version.
|
||||
func TestNegotiateAPIVersionEmpty(t *testing.T) {
|
||||
defer env.PatchAll(t, map[string]string{"DOCKER_API_VERSION": ""})()
|
||||
t.Setenv("DOCKER_API_VERSION", "")
|
||||
|
||||
client, err := NewClientWithOpts(FromEnv)
|
||||
assert.NilError(t, err)
|
||||
|
@ -289,7 +289,7 @@ func TestNegotiateAPIVersion(t *testing.T) {
|
|||
// environment variable when negotiating versions.
|
||||
func TestNegotiateAPVersionOverride(t *testing.T) {
|
||||
const expected = "9.99"
|
||||
defer env.PatchAll(t, map[string]string{"DOCKER_API_VERSION": expected})()
|
||||
t.Setenv("DOCKER_API_VERSION", expected)
|
||||
|
||||
client, err := NewClientWithOpts(FromEnv)
|
||||
assert.NilError(t, err)
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
|
||||
"github.com/docker/docker/api"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/env"
|
||||
)
|
||||
|
||||
func TestOptionWithHostFromEnv(t *testing.T) {
|
||||
|
@ -18,7 +17,7 @@ func TestOptionWithHostFromEnv(t *testing.T) {
|
|||
assert.Equal(t, c.addr, defaultAddr)
|
||||
assert.Equal(t, c.basePath, "")
|
||||
|
||||
defer env.Patch(t, "DOCKER_HOST", "tcp://foo.example.com:2376/test/")()
|
||||
t.Setenv("DOCKER_HOST", "tcp://foo.example.com:2376/test/")
|
||||
|
||||
c, err = NewClientWithOpts(WithHostFromEnv())
|
||||
assert.NilError(t, err)
|
||||
|
@ -44,7 +43,7 @@ func TestOptionWithVersionFromEnv(t *testing.T) {
|
|||
assert.Equal(t, c.version, api.DefaultVersion)
|
||||
assert.Equal(t, c.manualOverride, false)
|
||||
|
||||
defer env.Patch(t, "DOCKER_API_VERSION", "2.9999")()
|
||||
t.Setenv("DOCKER_API_VERSION", "2.9999")
|
||||
|
||||
c, err = NewClientWithOpts(WithVersionFromEnv())
|
||||
assert.NilError(t, err)
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
|
||||
"github.com/docker/docker/daemon/logger"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/env"
|
||||
)
|
||||
|
||||
// Validate options
|
||||
|
@ -85,8 +84,7 @@ func TestNewMissedToken(t *testing.T) {
|
|||
|
||||
func TestNewWithProxy(t *testing.T) {
|
||||
proxy := "http://proxy.testing:8888"
|
||||
reset := env.Patch(t, "HTTP_PROXY", proxy)
|
||||
defer reset()
|
||||
t.Setenv("HTTP_PROXY", proxy)
|
||||
|
||||
// must not be localhost
|
||||
splunkURL := "http://example.com:12345"
|
||||
|
|
|
@ -18,7 +18,6 @@ import (
|
|||
"github.com/docker/docker/testutil/daemon"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/env"
|
||||
"gotest.tools/v3/skip"
|
||||
)
|
||||
|
||||
|
@ -213,9 +212,9 @@ func TestDaemonProxy(t *testing.T) {
|
|||
|
||||
// Configure proxy through env-vars
|
||||
t.Run("environment variables", func(t *testing.T) {
|
||||
defer env.Patch(t, "HTTP_PROXY", proxyServer.URL)()
|
||||
defer env.Patch(t, "HTTPS_PROXY", proxyServer.URL)()
|
||||
defer env.Patch(t, "NO_PROXY", "example.com")()
|
||||
t.Setenv("HTTP_PROXY", proxyServer.URL)
|
||||
t.Setenv("HTTPS_PROXY", proxyServer.URL)
|
||||
t.Setenv("NO_PROXY", "example.com")
|
||||
|
||||
d := daemon.New(t)
|
||||
c := d.NewClientT(t)
|
||||
|
@ -241,12 +240,12 @@ func TestDaemonProxy(t *testing.T) {
|
|||
|
||||
// Configure proxy through command-line flags
|
||||
t.Run("command-line options", func(t *testing.T) {
|
||||
defer env.Patch(t, "HTTP_PROXY", "http://"+userPass+"from-env-http.invalid")()
|
||||
defer env.Patch(t, "http_proxy", "http://"+userPass+"from-env-http.invalid")()
|
||||
defer env.Patch(t, "HTTPS_PROXY", "https://"+userPass+"myuser:mypassword@from-env-https.invalid")()
|
||||
defer env.Patch(t, "https_proxy", "https://"+userPass+"myuser:mypassword@from-env-https.invalid")()
|
||||
defer env.Patch(t, "NO_PROXY", "ignore.invalid")()
|
||||
defer env.Patch(t, "no_proxy", "ignore.invalid")()
|
||||
t.Setenv("HTTP_PROXY", "http://"+userPass+"from-env-http.invalid")
|
||||
t.Setenv("http_proxy", "http://"+userPass+"from-env-http.invalid")
|
||||
t.Setenv("HTTPS_PROXY", "https://"+userPass+"myuser:mypassword@from-env-https.invalid")
|
||||
t.Setenv("https_proxy", "https://"+userPass+"myuser:mypassword@from-env-https.invalid")
|
||||
t.Setenv("NO_PROXY", "ignore.invalid")
|
||||
t.Setenv("no_proxy", "ignore.invalid")
|
||||
|
||||
d := daemon.New(t)
|
||||
d.Start(t, "--http-proxy", proxyServer.URL, "--https-proxy", proxyServer.URL, "--no-proxy", "example.com")
|
||||
|
@ -282,12 +281,12 @@ func TestDaemonProxy(t *testing.T) {
|
|||
|
||||
// Configure proxy through configuration file
|
||||
t.Run("configuration file", func(t *testing.T) {
|
||||
defer env.Patch(t, "HTTP_PROXY", "http://"+userPass+"from-env-http.invalid")()
|
||||
defer env.Patch(t, "http_proxy", "http://"+userPass+"from-env-http.invalid")()
|
||||
defer env.Patch(t, "HTTPS_PROXY", "https://"+userPass+"myuser:mypassword@from-env-https.invalid")()
|
||||
defer env.Patch(t, "https_proxy", "https://"+userPass+"myuser:mypassword@from-env-https.invalid")()
|
||||
defer env.Patch(t, "NO_PROXY", "ignore.invalid")()
|
||||
defer env.Patch(t, "no_proxy", "ignore.invalid")()
|
||||
t.Setenv("HTTP_PROXY", "http://"+userPass+"from-env-http.invalid")
|
||||
t.Setenv("http_proxy", "http://"+userPass+"from-env-http.invalid")
|
||||
t.Setenv("HTTPS_PROXY", "https://"+userPass+"myuser:mypassword@from-env-https.invalid")
|
||||
t.Setenv("https_proxy", "https://"+userPass+"myuser:mypassword@from-env-https.invalid")
|
||||
t.Setenv("NO_PROXY", "ignore.invalid")
|
||||
t.Setenv("no_proxy", "ignore.invalid")
|
||||
|
||||
d := daemon.New(t)
|
||||
c := d.NewClientT(t)
|
||||
|
|
Loading…
Reference in a new issue