mirror of https://github.com/docker/cli.git
linting: os.Setenv() can be replaced by `t.Setenv()` (tenv)
cli/command/cli_options_test.go:29:2: os.Setenv() can be replaced by `t.Setenv()` in TestWithContentTrustFromEnv (tenv) os.Setenv(envvar, "true") ^ cli/command/cli_options_test.go:31:2: os.Setenv() can be replaced by `t.Setenv()` in TestWithContentTrustFromEnv (tenv) os.Setenv(envvar, "false") ^ cli/command/cli_options_test.go:33:2: os.Setenv() can be replaced by `t.Setenv()` in TestWithContentTrustFromEnv (tenv) os.Setenv(envvar, "invalid") ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
ce01160e74
commit
cef858170d
|
@ -15,23 +15,13 @@ func contentTrustEnabled(t *testing.T) bool {
|
||||||
|
|
||||||
// NB: Do not t.Parallel() this test -- it messes with the process environment.
|
// NB: Do not t.Parallel() this test -- it messes with the process environment.
|
||||||
func TestWithContentTrustFromEnv(t *testing.T) {
|
func TestWithContentTrustFromEnv(t *testing.T) {
|
||||||
envvar := "DOCKER_CONTENT_TRUST"
|
const envvar = "DOCKER_CONTENT_TRUST"
|
||||||
if orig, ok := os.LookupEnv(envvar); ok {
|
t.Setenv(envvar, "true")
|
||||||
defer func() {
|
assert.Check(t, contentTrustEnabled(t))
|
||||||
os.Setenv(envvar, orig)
|
t.Setenv(envvar, "false")
|
||||||
}()
|
assert.Check(t, !contentTrustEnabled(t))
|
||||||
} else {
|
t.Setenv(envvar, "invalid")
|
||||||
defer func() {
|
assert.Check(t, contentTrustEnabled(t))
|
||||||
os.Unsetenv(envvar)
|
os.Unsetenv(envvar)
|
||||||
}()
|
assert.Check(t, !contentTrustEnabled(t))
|
||||||
}
|
|
||||||
|
|
||||||
os.Setenv(envvar, "true")
|
|
||||||
assert.Assert(t, contentTrustEnabled(t))
|
|
||||||
os.Setenv(envvar, "false")
|
|
||||||
assert.Assert(t, !contentTrustEnabled(t))
|
|
||||||
os.Setenv(envvar, "invalid")
|
|
||||||
assert.Assert(t, contentTrustEnabled(t))
|
|
||||||
os.Unsetenv(envvar)
|
|
||||||
assert.Assert(t, !contentTrustEnabled(t))
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue