mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Update tests to use gotestyourself/fs
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
47962ee32f
commit
60672382c7
5 changed files with 45 additions and 45 deletions
|
@ -3,14 +3,14 @@ package dockerfile
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/testutil/tempfile"
|
"github.com/gotestyourself/gotestyourself/fs"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIsExistingDirectory(t *testing.T) {
|
func TestIsExistingDirectory(t *testing.T) {
|
||||||
tmpfile := tempfile.NewTempFile(t, "file-exists-test", "something")
|
tmpfile := fs.NewFile(t, "file-exists-test", fs.WithContent("something"))
|
||||||
defer tmpfile.Remove()
|
defer tmpfile.Remove()
|
||||||
tmpdir := tempfile.NewTempDir(t, "dir-exists-test")
|
tmpdir := fs.NewDir(t, "dir-exists-test")
|
||||||
defer tmpdir.Remove()
|
defer tmpdir.Remove()
|
||||||
|
|
||||||
var testcases = []struct {
|
var testcases = []struct {
|
||||||
|
@ -20,7 +20,7 @@ func TestIsExistingDirectory(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
doc: "directory exists",
|
doc: "directory exists",
|
||||||
path: tmpdir.Path,
|
path: tmpdir.Path(),
|
||||||
expected: true,
|
expected: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ func TestIsExistingDirectory(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
doc: "file exists",
|
doc: "file exists",
|
||||||
path: tmpfile.Name(),
|
path: tmpfile.Path(),
|
||||||
expected: false,
|
expected: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/daemon/config"
|
"github.com/docker/docker/daemon/config"
|
||||||
"github.com/docker/docker/pkg/testutil"
|
"github.com/docker/docker/pkg/testutil"
|
||||||
"github.com/docker/docker/pkg/testutil/tempfile"
|
"github.com/gotestyourself/gotestyourself/fs"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -46,9 +46,9 @@ func TestLoadDaemonCliConfigWithTLS(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadDaemonCliConfigWithConflicts(t *testing.T) {
|
func TestLoadDaemonCliConfigWithConflicts(t *testing.T) {
|
||||||
tempFile := tempfile.NewTempFile(t, "config", `{"labels": ["l3=foo"]}`)
|
tempFile := fs.NewFile(t, "config", fs.WithContent(`{"labels": ["l3=foo"]}`))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
configFile := tempFile.Name()
|
configFile := tempFile.Path()
|
||||||
|
|
||||||
opts := defaultOptions(configFile)
|
opts := defaultOptions(configFile)
|
||||||
flags := opts.flags
|
flags := opts.flags
|
||||||
|
@ -62,10 +62,10 @@ func TestLoadDaemonCliConfigWithConflicts(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) {
|
func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) {
|
||||||
tempFile := tempfile.NewTempFile(t, "config", `{"tlsverify": true}`)
|
tempFile := fs.NewFile(t, "config", fs.WithContent(`{"tlsverify": true}`))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
|
|
||||||
opts := defaultOptions(tempFile.Name())
|
opts := defaultOptions(tempFile.Path())
|
||||||
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
||||||
|
|
||||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||||
|
@ -75,10 +75,10 @@ func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) {
|
func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) {
|
||||||
tempFile := tempfile.NewTempFile(t, "config", `{"tlsverify": false}`)
|
tempFile := fs.NewFile(t, "config", fs.WithContent(`{"tlsverify": false}`))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
|
|
||||||
opts := defaultOptions(tempFile.Name())
|
opts := defaultOptions(tempFile.Path())
|
||||||
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
||||||
|
|
||||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||||
|
@ -88,10 +88,10 @@ func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) {
|
func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) {
|
||||||
tempFile := tempfile.NewTempFile(t, "config", `{}`)
|
tempFile := fs.NewFile(t, "config", fs.WithContent(`{}`))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
|
|
||||||
opts := defaultOptions(tempFile.Name())
|
opts := defaultOptions(tempFile.Path())
|
||||||
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
||||||
|
|
||||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||||
|
@ -101,10 +101,10 @@ func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
|
func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
|
||||||
tempFile := tempfile.NewTempFile(t, "config", `{"log-level": "warn"}`)
|
tempFile := fs.NewFile(t, "config", fs.WithContent(`{"log-level": "warn"}`))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
|
|
||||||
opts := defaultOptions(tempFile.Name())
|
opts := defaultOptions(tempFile.Path())
|
||||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, loadedConfig)
|
require.NotNil(t, loadedConfig)
|
||||||
|
@ -114,10 +114,10 @@ func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
|
||||||
|
|
||||||
func TestLoadDaemonConfigWithEmbeddedOptions(t *testing.T) {
|
func TestLoadDaemonConfigWithEmbeddedOptions(t *testing.T) {
|
||||||
content := `{"tlscacert": "/etc/certs/ca.pem", "log-driver": "syslog"}`
|
content := `{"tlscacert": "/etc/certs/ca.pem", "log-driver": "syslog"}`
|
||||||
tempFile := tempfile.NewTempFile(t, "config", content)
|
tempFile := fs.NewFile(t, "config", fs.WithContent(content))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
|
|
||||||
opts := defaultOptions(tempFile.Name())
|
opts := defaultOptions(tempFile.Path())
|
||||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, loadedConfig)
|
require.NotNil(t, loadedConfig)
|
||||||
|
@ -131,10 +131,10 @@ func TestLoadDaemonConfigWithRegistryOptions(t *testing.T) {
|
||||||
"registry-mirrors": ["https://mirrors.docker.com"],
|
"registry-mirrors": ["https://mirrors.docker.com"],
|
||||||
"insecure-registries": ["https://insecure.docker.com"]
|
"insecure-registries": ["https://insecure.docker.com"]
|
||||||
}`
|
}`
|
||||||
tempFile := tempfile.NewTempFile(t, "config", content)
|
tempFile := fs.NewFile(t, "config", fs.WithContent(content))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
|
|
||||||
opts := defaultOptions(tempFile.Name())
|
opts := defaultOptions(tempFile.Path())
|
||||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, loadedConfig)
|
require.NotNil(t, loadedConfig)
|
||||||
|
|
|
@ -9,17 +9,17 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/daemon/config"
|
"github.com/docker/docker/daemon/config"
|
||||||
"github.com/docker/docker/pkg/testutil/tempfile"
|
"github.com/gotestyourself/gotestyourself/fs"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) {
|
func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) {
|
||||||
content := `{"log-opts": {"max-size": "1k"}}`
|
content := `{"log-opts": {"max-size": "1k"}}`
|
||||||
tempFile := tempfile.NewTempFile(t, "config", content)
|
tempFile := fs.NewFile(t, "config", fs.WithContent(content))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
|
|
||||||
opts := defaultOptions(tempFile.Name())
|
opts := defaultOptions(tempFile.Path())
|
||||||
opts.Debug = true
|
opts.Debug = true
|
||||||
opts.LogLevel = "info"
|
opts.LogLevel = "info"
|
||||||
assert.NoError(t, opts.flags.Set("selinux-enabled", "true"))
|
assert.NoError(t, opts.flags.Set("selinux-enabled", "true"))
|
||||||
|
@ -37,10 +37,10 @@ func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) {
|
||||||
|
|
||||||
func TestLoadDaemonConfigWithNetwork(t *testing.T) {
|
func TestLoadDaemonConfigWithNetwork(t *testing.T) {
|
||||||
content := `{"bip": "127.0.0.2", "ip": "127.0.0.1"}`
|
content := `{"bip": "127.0.0.2", "ip": "127.0.0.1"}`
|
||||||
tempFile := tempfile.NewTempFile(t, "config", content)
|
tempFile := fs.NewFile(t, "config", fs.WithContent(content))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
|
|
||||||
opts := defaultOptions(tempFile.Name())
|
opts := defaultOptions(tempFile.Path())
|
||||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, loadedConfig)
|
require.NotNil(t, loadedConfig)
|
||||||
|
@ -54,10 +54,10 @@ func TestLoadDaemonConfigWithMapOptions(t *testing.T) {
|
||||||
"cluster-store-opts": {"kv.cacertfile": "/var/lib/docker/discovery_certs/ca.pem"},
|
"cluster-store-opts": {"kv.cacertfile": "/var/lib/docker/discovery_certs/ca.pem"},
|
||||||
"log-opts": {"tag": "test"}
|
"log-opts": {"tag": "test"}
|
||||||
}`
|
}`
|
||||||
tempFile := tempfile.NewTempFile(t, "config", content)
|
tempFile := fs.NewFile(t, "config", fs.WithContent(content))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
|
|
||||||
opts := defaultOptions(tempFile.Name())
|
opts := defaultOptions(tempFile.Path())
|
||||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, loadedConfig)
|
require.NotNil(t, loadedConfig)
|
||||||
|
@ -71,10 +71,10 @@ func TestLoadDaemonConfigWithMapOptions(t *testing.T) {
|
||||||
|
|
||||||
func TestLoadDaemonConfigWithTrueDefaultValues(t *testing.T) {
|
func TestLoadDaemonConfigWithTrueDefaultValues(t *testing.T) {
|
||||||
content := `{ "userland-proxy": false }`
|
content := `{ "userland-proxy": false }`
|
||||||
tempFile := tempfile.NewTempFile(t, "config", content)
|
tempFile := fs.NewFile(t, "config", fs.WithContent(content))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
|
|
||||||
opts := defaultOptions(tempFile.Name())
|
opts := defaultOptions(tempFile.Path())
|
||||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, loadedConfig)
|
require.NotNil(t, loadedConfig)
|
||||||
|
@ -90,10 +90,10 @@ func TestLoadDaemonConfigWithTrueDefaultValues(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadDaemonConfigWithTrueDefaultValuesLeaveDefaults(t *testing.T) {
|
func TestLoadDaemonConfigWithTrueDefaultValuesLeaveDefaults(t *testing.T) {
|
||||||
tempFile := tempfile.NewTempFile(t, "config", `{}`)
|
tempFile := fs.NewFile(t, "config", fs.WithContent(`{}`))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
|
|
||||||
opts := defaultOptions(tempFile.Name())
|
opts := defaultOptions(tempFile.Path())
|
||||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, loadedConfig)
|
require.NotNil(t, loadedConfig)
|
||||||
|
@ -103,10 +103,10 @@ func TestLoadDaemonConfigWithTrueDefaultValuesLeaveDefaults(t *testing.T) {
|
||||||
|
|
||||||
func TestLoadDaemonConfigWithLegacyRegistryOptions(t *testing.T) {
|
func TestLoadDaemonConfigWithLegacyRegistryOptions(t *testing.T) {
|
||||||
content := `{"disable-legacy-registry": false}`
|
content := `{"disable-legacy-registry": false}`
|
||||||
tempFile := tempfile.NewTempFile(t, "config", content)
|
tempFile := fs.NewFile(t, "config", fs.WithContent(content))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
|
|
||||||
opts := defaultOptions(tempFile.Name())
|
opts := defaultOptions(tempFile.Path())
|
||||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, loadedConfig)
|
require.NotNil(t, loadedConfig)
|
||||||
|
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/opts"
|
"github.com/docker/docker/opts"
|
||||||
"github.com/docker/docker/pkg/testutil/tempfile"
|
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
|
"github.com/gotestyourself/gotestyourself/fs"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -29,7 +29,7 @@ func TestGetConflictFreeConfiguration(t *testing.T) {
|
||||||
}
|
}
|
||||||
}`))
|
}`))
|
||||||
|
|
||||||
file := tempfile.NewTempFile(t, "docker-config", configFileData)
|
file := fs.NewFile(t, "docker-config", fs.WithContent(configFileData))
|
||||||
defer file.Remove()
|
defer file.Remove()
|
||||||
|
|
||||||
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
||||||
|
@ -38,7 +38,7 @@ func TestGetConflictFreeConfiguration(t *testing.T) {
|
||||||
flags.Var(opts.NewNamedUlimitOpt("default-ulimits", nil), "default-ulimit", "")
|
flags.Var(opts.NewNamedUlimitOpt("default-ulimits", nil), "default-ulimit", "")
|
||||||
flags.Var(opts.NewNamedMapOpts("log-opts", nil, nil), "log-opt", "")
|
flags.Var(opts.NewNamedMapOpts("log-opts", nil, nil), "log-opt", "")
|
||||||
|
|
||||||
cc, err := getConflictFreeConfiguration(file.Name(), flags)
|
cc, err := getConflictFreeConfiguration(file.Path(), flags)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.True(t, cc.Debug)
|
assert.True(t, cc.Debug)
|
||||||
|
@ -70,7 +70,7 @@ func TestDaemonConfigurationMerge(t *testing.T) {
|
||||||
}
|
}
|
||||||
}`))
|
}`))
|
||||||
|
|
||||||
file := tempfile.NewTempFile(t, "docker-config", configFileData)
|
file := fs.NewFile(t, "docker-config", fs.WithContent(configFileData))
|
||||||
defer file.Remove()
|
defer file.Remove()
|
||||||
|
|
||||||
c := &Config{
|
c := &Config{
|
||||||
|
@ -90,7 +90,7 @@ func TestDaemonConfigurationMerge(t *testing.T) {
|
||||||
flags.Var(opts.NewNamedUlimitOpt("default-ulimits", nil), "default-ulimit", "")
|
flags.Var(opts.NewNamedUlimitOpt("default-ulimits", nil), "default-ulimit", "")
|
||||||
flags.Var(opts.NewNamedMapOpts("log-opts", nil, nil), "log-opt", "")
|
flags.Var(opts.NewNamedMapOpts("log-opts", nil, nil), "log-opt", "")
|
||||||
|
|
||||||
cc, err := MergeDaemonConfigurations(c, flags, file.Name())
|
cc, err := MergeDaemonConfigurations(c, flags, file.Path())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.True(t, cc.Debug)
|
assert.True(t, cc.Debug)
|
||||||
|
@ -120,7 +120,7 @@ func TestDaemonConfigurationMergeShmSize(t *testing.T) {
|
||||||
"default-shm-size": "1g"
|
"default-shm-size": "1g"
|
||||||
}`))
|
}`))
|
||||||
|
|
||||||
file := tempfile.NewTempFile(t, "docker-config", data)
|
file := fs.NewFile(t, "docker-config", fs.WithContent(data))
|
||||||
defer file.Remove()
|
defer file.Remove()
|
||||||
|
|
||||||
c := &Config{}
|
c := &Config{}
|
||||||
|
@ -129,7 +129,7 @@ func TestDaemonConfigurationMergeShmSize(t *testing.T) {
|
||||||
shmSize := opts.MemBytes(DefaultShmSize)
|
shmSize := opts.MemBytes(DefaultShmSize)
|
||||||
flags.Var(&shmSize, "default-shm-size", "")
|
flags.Var(&shmSize, "default-shm-size", "")
|
||||||
|
|
||||||
cc, err := MergeDaemonConfigurations(c, flags, file.Name())
|
cc, err := MergeDaemonConfigurations(c, flags, file.Path())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
expectedValue := 1 * 1024 * 1024 * 1024
|
expectedValue := 1 * 1024 * 1024 * 1024
|
||||||
|
|
|
@ -23,11 +23,11 @@ import (
|
||||||
"github.com/docker/docker/integration-cli/cli"
|
"github.com/docker/docker/integration-cli/cli"
|
||||||
"github.com/docker/docker/integration-cli/daemon"
|
"github.com/docker/docker/integration-cli/daemon"
|
||||||
icmd "github.com/docker/docker/pkg/testutil/cmd"
|
icmd "github.com/docker/docker/pkg/testutil/cmd"
|
||||||
"github.com/docker/docker/pkg/testutil/tempfile"
|
|
||||||
"github.com/docker/libnetwork/driverapi"
|
"github.com/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/libnetwork/ipamapi"
|
"github.com/docker/libnetwork/ipamapi"
|
||||||
remoteipam "github.com/docker/libnetwork/ipams/remote/api"
|
remoteipam "github.com/docker/libnetwork/ipams/remote/api"
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
|
"github.com/gotestyourself/gotestyourself/fs"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -67,11 +67,11 @@ func (s *DockerSwarmSuite) TestSwarmUpdate(c *check.C) {
|
||||||
c.Assert(spec.CAConfig.ExternalCAs[1].CACert, checker.Equals, string(expected))
|
c.Assert(spec.CAConfig.ExternalCAs[1].CACert, checker.Equals, string(expected))
|
||||||
|
|
||||||
// passing an invalid external CA fails
|
// passing an invalid external CA fails
|
||||||
tempFile := tempfile.NewTempFile(c, "testfile", "fakecert")
|
tempFile := fs.NewFile(c, "testfile", fs.WithContent("fakecert"))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
|
|
||||||
result := cli.Docker(cli.Args("swarm", "update",
|
result := cli.Docker(cli.Args("swarm", "update",
|
||||||
"--external-ca", fmt.Sprintf("protocol=cfssl,url=https://something.org,cacert=%s", tempFile.Name())),
|
"--external-ca", fmt.Sprintf("protocol=cfssl,url=https://something.org,cacert=%s", tempFile.Path())),
|
||||||
cli.Daemon(d.Daemon))
|
cli.Daemon(d.Daemon))
|
||||||
result.Assert(c, icmd.Expected{
|
result.Assert(c, icmd.Expected{
|
||||||
ExitCode: 125,
|
ExitCode: 125,
|
||||||
|
@ -88,11 +88,11 @@ func (s *DockerSwarmSuite) TestSwarmInit(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// passing an invalid external CA fails
|
// passing an invalid external CA fails
|
||||||
tempFile := tempfile.NewTempFile(c, "testfile", "fakecert")
|
tempFile := fs.NewFile(c, "testfile", fs.WithContent("fakecert"))
|
||||||
defer tempFile.Remove()
|
defer tempFile.Remove()
|
||||||
|
|
||||||
result := cli.Docker(cli.Args("swarm", "init", "--cert-expiry", "30h", "--dispatcher-heartbeat", "11s",
|
result := cli.Docker(cli.Args("swarm", "init", "--cert-expiry", "30h", "--dispatcher-heartbeat", "11s",
|
||||||
"--external-ca", fmt.Sprintf("protocol=cfssl,url=https://somethingelse.org,cacert=%s", tempFile.Name())),
|
"--external-ca", fmt.Sprintf("protocol=cfssl,url=https://somethingelse.org,cacert=%s", tempFile.Path())),
|
||||||
cli.Daemon(d.Daemon))
|
cli.Daemon(d.Daemon))
|
||||||
result.Assert(c, icmd.Expected{
|
result.Assert(c, icmd.Expected{
|
||||||
ExitCode: 125,
|
ExitCode: 125,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue