mirror of
https://github.com/moby/moby.git
synced 2025-07-29 07:21:35 +03:00
test: use T.Setenv
to set env vars in tests
This commit replaces `os.Setenv` with `t.Setenv` in tests. The environment variable is automatically restored to its original value when the test and all its subtests complete. Reference: https://pkg.go.dev/testing#T.Setenv Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@ -1693,12 +1693,7 @@ func (s *DockerDaemonSuite) TestDaemonStartWithDefaultTLSHost(c *testing.T) {
|
||||
"--tlskey", "fixtures/https/server-key.pem")
|
||||
|
||||
// The client with --tlsverify should also use default host localhost:2376
|
||||
tmpHost := os.Getenv("DOCKER_HOST")
|
||||
defer func() {
|
||||
os.Setenv("DOCKER_HOST", tmpHost)
|
||||
}()
|
||||
|
||||
os.Setenv("DOCKER_HOST", "")
|
||||
c.Setenv("DOCKER_HOST", "")
|
||||
|
||||
out, _ := dockerCmd(
|
||||
c,
|
||||
|
Reference in New Issue
Block a user