mirror of https://github.com/docker/cli.git
28 lines
658 B
Go
28 lines
658 B
Go
package command
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"gotest.tools/v3/assert"
|
|
)
|
|
|
|
func contentTrustEnabled(t *testing.T) bool {
|
|
var cli DockerCli
|
|
assert.NilError(t, WithContentTrustFromEnv()(&cli))
|
|
return cli.contentTrust
|
|
}
|
|
|
|
// NB: Do not t.Parallel() this test -- it messes with the process environment.
|
|
func TestWithContentTrustFromEnv(t *testing.T) {
|
|
const envvar = "DOCKER_CONTENT_TRUST"
|
|
t.Setenv(envvar, "true")
|
|
assert.Check(t, contentTrustEnabled(t))
|
|
t.Setenv(envvar, "false")
|
|
assert.Check(t, !contentTrustEnabled(t))
|
|
t.Setenv(envvar, "invalid")
|
|
assert.Check(t, contentTrustEnabled(t))
|
|
os.Unsetenv(envvar)
|
|
assert.Check(t, !contentTrustEnabled(t))
|
|
}
|