mirror of https://github.com/docker/cli.git
Merge pull request #921 from dnephin/use-canonical-imports
testing: Use canonical asserts
This commit is contained in:
commit
0e3677ead5
|
@ -26,7 +26,7 @@ func TestLoadFileV01Success(t *testing.T) {
|
|||
}`)
|
||||
|
||||
bundle, err := LoadFile(reader)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal("0.1", bundle.Version))
|
||||
assert.Check(t, is.Len(bundle.Services, 2))
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func TestLoadFileSyntaxError(t *testing.T) {
|
|||
}`)
|
||||
|
||||
_, err := LoadFile(reader)
|
||||
assert.Check(t, is.Error(err, "JSON syntax error at byte 37: invalid character 'u' looking for beginning of value"))
|
||||
assert.Error(t, err, "JSON syntax error at byte 37: invalid character 'u' looking for beginning of value")
|
||||
}
|
||||
|
||||
func TestLoadFileTypeError(t *testing.T) {
|
||||
|
@ -53,7 +53,7 @@ func TestLoadFileTypeError(t *testing.T) {
|
|||
}`)
|
||||
|
||||
_, err := LoadFile(reader)
|
||||
assert.Check(t, is.Error(err, "Unexpected type at byte 94. Expected []string but received string."))
|
||||
assert.Error(t, err, "Unexpected type at byte 94. Expected []string but received string.")
|
||||
}
|
||||
|
||||
func TestPrint(t *testing.T) {
|
||||
|
|
|
@ -63,7 +63,7 @@ func TestCheckpointCreateWithOptions(t *testing.T) {
|
|||
cmd.SetArgs([]string{"container-foo", checkpoint})
|
||||
cmd.Flags().Set("leave-running", "true")
|
||||
cmd.Flags().Set("checkpoint-dir", "/dir/foo")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("container-foo", containerID))
|
||||
assert.Check(t, is.Equal(checkpoint, checkpointID))
|
||||
assert.Check(t, is.Equal("/dir/foo", checkpointDir))
|
||||
|
|
|
@ -60,7 +60,7 @@ func TestCheckpointListWithOptions(t *testing.T) {
|
|||
cmd := newListCommand(cli)
|
||||
cmd.SetArgs([]string{"container-foo"})
|
||||
cmd.Flags().Set("checkpoint-dir", "/dir/foo")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("container-foo", containerID))
|
||||
assert.Check(t, is.Equal("/dir/foo", checkpointDir))
|
||||
golden.Assert(t, cli.OutBuffer().String(), "checkpoint-list-with-options.golden")
|
||||
|
|
|
@ -58,7 +58,7 @@ func TestCheckpointRemoveWithOptions(t *testing.T) {
|
|||
cmd := newRemoveCommand(cli)
|
||||
cmd.SetArgs([]string{"container-foo", "checkpoint-bar"})
|
||||
cmd.Flags().Set("checkpoint-dir", "/dir/foo")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("container-foo", containerID))
|
||||
assert.Check(t, is.Equal("checkpoint-bar", checkpointID))
|
||||
assert.Check(t, is.Equal("/dir/foo", checkpointDir))
|
||||
|
|
|
@ -163,7 +163,7 @@ func TestExperimentalCLI(t *testing.T) {
|
|||
cli := &DockerCli{client: apiclient, err: os.Stderr}
|
||||
cliconfig.SetDir(dir.Path())
|
||||
err := cli.Initialize(flags.NewClientOptions())
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(testcase.expectedExperimentalCLI, cli.ClientInfo().HasExperimental))
|
||||
})
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ func TestOrchestratorSwitch(t *testing.T) {
|
|||
options.Common.Orchestrator = testcase.flagOrchestrator
|
||||
}
|
||||
err := cli.Initialize(options)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(testcase.expectedKubernetes, cli.ClientInfo().HasKubernetes()))
|
||||
assert.Check(t, is.Equal(testcase.expectedOrchestrator, string(cli.ClientInfo().Orchestrator)))
|
||||
})
|
||||
|
@ -334,7 +334,7 @@ func TestGetClientWithPassword(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ func TestConfigCreateWithName(t *testing.T) {
|
|||
|
||||
cmd := newConfigCreateCommand(cli)
|
||||
cmd.SetArgs([]string{name, filepath.Join("testdata", configDataFile)})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, string(actual), configDataFile)
|
||||
assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ func TestConfigCreateWithLabels(t *testing.T) {
|
|||
name := "foo"
|
||||
|
||||
data, err := ioutil.ReadFile(filepath.Join("testdata", configDataFile))
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
expected := swarm.ConfigSpec{
|
||||
Annotations: swarm.Annotations{
|
||||
|
@ -109,7 +109,7 @@ func TestConfigCreateWithLabels(t *testing.T) {
|
|||
cmd.SetArgs([]string{name, filepath.Join("testdata", configDataFile)})
|
||||
cmd.Flags().Set("label", "lbl1=Label-foo")
|
||||
cmd.Flags().Set("label", "lbl2=Label-bar")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
|
||||
}
|
||||
|
||||
|
@ -138,6 +138,6 @@ func TestConfigCreateWithTemplatingDriver(t *testing.T) {
|
|||
cmd := newConfigCreateCommand(cli)
|
||||
cmd.SetArgs([]string{name, filepath.Join("testdata", configDataFile)})
|
||||
cmd.Flags().Set("template-driver", expectedDriver.Name)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ func TestConfigInspectWithoutFormat(t *testing.T) {
|
|||
cli := test.NewFakeCli(&fakeClient{configInspectFunc: tc.configInspectFunc})
|
||||
cmd := newConfigInspectCommand(cli)
|
||||
cmd.SetArgs(tc.args)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("config-inspect-without-format.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ func TestConfigInspectWithFormat(t *testing.T) {
|
|||
cmd := newConfigInspectCommand(cli)
|
||||
cmd.SetArgs(tc.args)
|
||||
cmd.Flags().Set("format", tc.format)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("config-inspect-with-format.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ func TestConfigInspectPretty(t *testing.T) {
|
|||
|
||||
cmd.SetArgs([]string{"configID"})
|
||||
cmd.Flags().Set("pretty", "true")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("config-inspect-pretty.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ func TestConfigList(t *testing.T) {
|
|||
},
|
||||
})
|
||||
cmd := newConfigListCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "config-list-sort.golden")
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ func TestConfigListWithQuietOption(t *testing.T) {
|
|||
})
|
||||
cmd := newConfigListCommand(cli)
|
||||
cmd.Flags().Set("quiet", "true")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "config-list-with-quiet-option.golden")
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ func TestConfigListWithConfigFormat(t *testing.T) {
|
|||
ConfigFormat: "{{ .Name }} {{ .Labels }}",
|
||||
})
|
||||
cmd := newConfigListCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "config-list-with-config-format.golden")
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ func TestConfigListWithFormat(t *testing.T) {
|
|||
})
|
||||
cmd := newConfigListCommand(cli)
|
||||
cmd.Flags().Set("format", "{{ .Name }} {{ .Labels }}")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "config-list-with-format.golden")
|
||||
}
|
||||
|
||||
|
@ -153,6 +153,6 @@ func TestConfigListWithFilter(t *testing.T) {
|
|||
cmd := newConfigListCommand(cli)
|
||||
cmd.Flags().Set("filter", "name=foo")
|
||||
cmd.Flags().Set("filter", "label=lbl1=Label-bar")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "config-list-with-filter.golden")
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ func TestConfigRemoveWithName(t *testing.T) {
|
|||
})
|
||||
cmd := newConfigRemoveCommand(cli)
|
||||
cmd.SetArgs(names)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.DeepEqual(names, strings.Split(strings.TrimSpace(cli.OutBuffer().String()), "\n")))
|
||||
assert.Check(t, is.DeepEqual(names, removedConfigs))
|
||||
}
|
||||
|
@ -74,6 +74,6 @@ func TestConfigRemoveContinueAfterError(t *testing.T) {
|
|||
cmd := newConfigRemoveCommand(cli)
|
||||
cmd.SetArgs(names)
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, is.Error(cmd.Execute(), "error removing config: foo"))
|
||||
assert.Error(t, cmd.Execute(), "error removing config: foo")
|
||||
assert.Check(t, is.DeepEqual(names, removedConfigs))
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
@ -122,9 +121,9 @@ func TestGetExitStatus(t *testing.T) {
|
|||
}
|
||||
err := getExitStatus(errC, resultC)
|
||||
if testcase.expectedError == nil {
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
} else {
|
||||
assert.Check(t, is.Error(err, testcase.expectedError.Error()))
|
||||
assert.Error(t, err, testcase.expectedError.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ func TestRunCopyWithInvalidArguments(t *testing.T) {
|
|||
for _, testcase := range testcases {
|
||||
t.Run(testcase.doc, func(t *testing.T) {
|
||||
err := runCopy(test.NewFakeCli(nil), testcase.options)
|
||||
assert.Check(t, is.Error(err, testcase.expectedErr))
|
||||
assert.Error(t, err, testcase.expectedErr)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ func TestCIDFileNoOPWithNoFilename(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
assert.DeepEqual(t, &cidFile{}, file, cmp.AllowUnexported(cidFile{}))
|
||||
|
||||
assert.Check(t, file.Write("id"))
|
||||
assert.Check(t, file.Close())
|
||||
assert.NilError(t, file.Write("id"))
|
||||
assert.NilError(t, file.Close())
|
||||
}
|
||||
|
||||
func TestNewCIDFileWhenFileAlreadyExists(t *testing.T) {
|
||||
|
@ -46,7 +46,7 @@ func TestCIDFileCloseWithNoWrite(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(file.path, path))
|
||||
|
||||
assert.Check(t, file.Close())
|
||||
assert.NilError(t, file.Close())
|
||||
_, err = os.Stat(path)
|
||||
assert.Check(t, os.IsNotExist(err))
|
||||
}
|
||||
|
@ -60,13 +60,13 @@ func TestCIDFileCloseWithWrite(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
|
||||
content := "id"
|
||||
assert.Check(t, file.Write(content))
|
||||
assert.NilError(t, file.Write(content))
|
||||
|
||||
actual, err := ioutil.ReadFile(path)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(content, string(actual)))
|
||||
|
||||
assert.Check(t, file.Close())
|
||||
assert.NilError(t, file.Close())
|
||||
_, err = os.Stat(path)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ func TestContainerListWithoutFormat(t *testing.T) {
|
|||
},
|
||||
})
|
||||
cmd := newListCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "container-list-without-format.golden")
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ func TestContainerListNoTrunc(t *testing.T) {
|
|||
})
|
||||
cmd := newListCommand(cli)
|
||||
cmd.Flags().Set("no-trunc", "true")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "container-list-without-format-no-trunc.golden")
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ func TestContainerListNamesMultipleTime(t *testing.T) {
|
|||
})
|
||||
cmd := newListCommand(cli)
|
||||
cmd.Flags().Set("format", "{{.Names}} {{.Names}}")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "container-list-format-name-name.golden")
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ func TestContainerListFormatTemplateWithArg(t *testing.T) {
|
|||
})
|
||||
cmd := newListCommand(cli)
|
||||
cmd.Flags().Set("format", `{{.Names}} {{.Label "some.label"}}`)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "container-list-format-with-arg.golden")
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ func TestContainerListFormatSizeSetsOption(t *testing.T) {
|
|||
})
|
||||
cmd := newListCommand(cli)
|
||||
cmd.Flags().Set("format", `{{.Size}}`)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
}
|
||||
|
||||
func TestContainerListWithConfigFormat(t *testing.T) {
|
||||
|
@ -144,7 +144,7 @@ func TestContainerListWithConfigFormat(t *testing.T) {
|
|||
PsFormat: "{{ .Names }} {{ .Image }} {{ .Labels }}",
|
||||
})
|
||||
cmd := newListCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "container-list-with-config-format.golden")
|
||||
}
|
||||
|
||||
|
@ -159,6 +159,6 @@ func TestContainerListWithFormat(t *testing.T) {
|
|||
})
|
||||
cmd := newListCommand(cli)
|
||||
cmd.Flags().Set("format", "{{ .Names }} {{ .Image }} {{ .Labels }}")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "container-list-with-format.golden")
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ func parseMustError(t *testing.T, args string) {
|
|||
|
||||
func mustParse(t *testing.T, args string) (*container.Config, *container.HostConfig) {
|
||||
config, hostConfig, _, err := parseRun(append(strings.Split(args, " "), "ubuntu", "bash"))
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
return config, hostConfig
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
|
||||
func TestBuildContainerListOptions(t *testing.T) {
|
||||
filters := opts.NewFilterOpt()
|
||||
assert.Check(t, filters.Set("foo=bar"))
|
||||
assert.Check(t, filters.Set("baz=foo"))
|
||||
assert.NilError(t, filters.Set("foo=bar"))
|
||||
assert.NilError(t, filters.Set("baz=foo"))
|
||||
|
||||
contexts := []struct {
|
||||
psOpts *psOptions
|
||||
|
@ -102,7 +102,7 @@ func TestBuildContainerListOptions(t *testing.T) {
|
|||
|
||||
for _, c := range contexts {
|
||||
options, err := buildContainerListOptions(c.psOpts)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
assert.Check(t, is.Equal(c.expectedAll, options.All))
|
||||
assert.Check(t, is.Equal(c.expectedSize, options.Size))
|
||||
|
|
|
@ -21,5 +21,5 @@ func TestRunLabel(t *testing.T) {
|
|||
cmd := NewRunCommand(cli)
|
||||
cmd.Flags().Set("detach", "true")
|
||||
cmd.SetArgs([]string{"--label", "foo", "busybox"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ size: 0B
|
|||
testcase.context.Output = out
|
||||
err := ContainerWrite(testcase.context, containers)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ D: /usr/app/old_app.js
|
|||
testcase.context.Output = out
|
||||
err := DiffWrite(testcase.context, diffs)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -294,7 +294,7 @@ image_id: imageID3
|
|||
testcase.context.Output = out
|
||||
err := ImageWrite(testcase.context, images)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ foobar_bar 2017-01-01 00:00:00 +0000 UTC
|
|||
testcase.context.Output = out
|
||||
err := NetworkWrite(testcase.context, networks)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ foobar_boo Unknown
|
|||
testcase.context.Output = out
|
||||
err := NodeWrite(testcase.context, nodes, types.Info{Swarm: swarm.Info{Cluster: &testcase.clusterInfo}})
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ foobar_bar
|
|||
testcase.context.Output = out
|
||||
err := PluginWrite(testcase.context, plugins)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ id_rsa
|
|||
out := bytes.NewBufferString("")
|
||||
testcase.context.Output = out
|
||||
if err := SecretWrite(testcase.context, secrets); err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ bar
|
|||
testcase.context.Output = out
|
||||
err := ServiceListWrite(testcase.context, services, info)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ container2 --
|
|||
te.context.Output = &out
|
||||
err := ContainerStatsWrite(te.context, stats, "linux", false)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, te.expected))
|
||||
assert.Error(t, err, te.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(te.expected, out.String()))
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ container2 -- --
|
|||
te.context.Output = &out
|
||||
err := ContainerStatsWrite(te.context, stats, "windows", false)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, te.expected))
|
||||
assert.Error(t, err, te.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(te.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ foobar_bar foo2
|
|||
testcase.context.Output = out
|
||||
err := TaskWrite(testcase.context, tasks, names, nodes)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ tag3 bbbbbbbb
|
|||
testcase.context.Output = out
|
||||
err := TrustTagWrite(testcase.context, signedTags)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ func TestTrustTagContextEmptyWrite(t *testing.T) {
|
|||
out := bytes.NewBufferString("")
|
||||
emptyCase.context.Output = out
|
||||
err := TrustTagWrite(emptyCase.context, emptySignedTags)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(emptyCase.expected, out.String()))
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ func TestSignerInfoContextEmptyWrite(t *testing.T) {
|
|||
out := bytes.NewBufferString("")
|
||||
emptyCase.context.Output = out
|
||||
err := SignerInfoWrite(emptyCase.context, emptySignerInfo)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(emptyCase.expected, out.String()))
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ eve foobarbazquxquux, key31, key32
|
|||
testcase.context.Output = out
|
||||
err := SignerInfoWrite(testcase.context, signerInfo)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ foobar_bar
|
|||
testcase.context.Output = out
|
||||
err := VolumeWrite(testcase.context, volumes)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ func TestResolveError(t *testing.T) {
|
|||
idResolver := New(cli, false)
|
||||
_, err := idResolver.Resolve(context.Background(), struct{}{}, "nodeID")
|
||||
|
||||
assert.Check(t, is.Error(err, "unsupported type"))
|
||||
assert.Error(t, err, "unsupported type")
|
||||
}
|
||||
|
||||
func TestResolveWithNoResolveOption(t *testing.T) {
|
||||
|
@ -41,7 +41,7 @@ func TestResolveWithNoResolveOption(t *testing.T) {
|
|||
idResolver := New(cli, true)
|
||||
id, err := idResolver.Resolve(context.Background(), swarm.Node{}, "nodeID")
|
||||
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal("nodeID", id))
|
||||
assert.Check(t, !resolved)
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ func TestResolveWithCache(t *testing.T) {
|
|||
ctx := context.Background()
|
||||
for i := 0; i < 2; i++ {
|
||||
id, err := idResolver.Resolve(ctx, swarm.Node{}, "nodeID")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal("node-foo", id))
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ func TestResolveNode(t *testing.T) {
|
|||
idResolver := New(cli, false)
|
||||
id, err := idResolver.Resolve(ctx, swarm.Node{}, tc.nodeID)
|
||||
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(tc.expectedID, id))
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ func TestResolveService(t *testing.T) {
|
|||
idResolver := New(cli, false)
|
||||
id, err := idResolver.Resolve(ctx, swarm.Service{}, tc.serviceID)
|
||||
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(tc.expectedID, id))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ func TestRunBuildResetsUidAndGidInContext(t *testing.T) {
|
|||
defer dest.Remove()
|
||||
|
||||
fakeImageBuild := func(_ context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) {
|
||||
assert.Check(t, archive.Untar(context, dest.Path(), nil))
|
||||
assert.NilError(t, archive.Untar(context, dest.Path(), nil))
|
||||
|
||||
body := new(bytes.Buffer)
|
||||
return types.ImageBuildResponse{Body: ioutil.NopCloser(body)}, nil
|
||||
|
@ -67,7 +67,7 @@ func TestRunBuildDockerfileFromStdinWithCompress(t *testing.T) {
|
|||
buffer := new(bytes.Buffer)
|
||||
tee := io.TeeReader(context, buffer)
|
||||
|
||||
assert.Check(t, archive.Untar(tee, dest, nil))
|
||||
assert.NilError(t, archive.Untar(tee, dest, nil))
|
||||
dockerfileName = options.Dockerfile
|
||||
|
||||
header := buffer.Bytes()[:10]
|
||||
|
@ -132,7 +132,7 @@ COPY data /data
|
|||
buffer := new(bytes.Buffer)
|
||||
tee := io.TeeReader(context, buffer)
|
||||
|
||||
assert.Check(t, archive.Untar(tee, dest, nil))
|
||||
assert.NilError(t, archive.Untar(tee, dest, nil))
|
||||
dockerfileName = options.Dockerfile
|
||||
|
||||
body := new(bytes.Buffer)
|
||||
|
|
|
@ -91,7 +91,7 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
|
|||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
err := cmd.Execute()
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
actual := cli.OutBuffer().String()
|
||||
golden.Assert(t, actual, fmt.Sprintf("history-command-success.%s.golden", tc.name))
|
||||
}
|
||||
|
|
|
@ -92,6 +92,6 @@ func TestNewImportCommandSuccess(t *testing.T) {
|
|||
cmd := NewImportCommand(test.NewFakeCli(&fakeClient{imageImportFunc: tc.imageImportFunc}))
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ func TestNewInspectCommandSuccess(t *testing.T) {
|
|||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
err := cmd.Execute()
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("inspect-command-success.%s.golden", tc.name))
|
||||
assert.Check(t, is.Equal(imageInspectInvocationCount, tc.imageCount))
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ func TestNewImagesCommandSuccess(t *testing.T) {
|
|||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
err := cmd.Execute()
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("list-command-success.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ func TestNewLoadCommandSuccess(t *testing.T) {
|
|||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
err := cmd.Execute()
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("load-command-success.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ func TestNewPruneCommandSuccess(t *testing.T) {
|
|||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
err := cmd.Execute()
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("prune-command-success.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ func TestNewPullCommandSuccess(t *testing.T) {
|
|||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
err := cmd.Execute()
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("pull-command-success.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,6 @@ func TestNewPushCommandSuccess(t *testing.T) {
|
|||
cmd := NewPushCommand(cli)
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ func TestNewRemoveCommandSuccess(t *testing.T) {
|
|||
cmd := NewRemoveCommand(cli)
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal(tc.expectedStderr, cli.ErrBuffer().String()))
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("remove-command-success.%s.golden", tc.name))
|
||||
})
|
||||
|
|
|
@ -95,7 +95,7 @@ func TestNewSaveCommandSuccess(t *testing.T) {
|
|||
}))
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
if tc.deferredFunc != nil {
|
||||
tc.deferredFunc()
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ func TestCliNewTagCommand(t *testing.T) {
|
|||
}))
|
||||
cmd.SetArgs([]string{"image1", "image2"})
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
value, _ := cmd.Flags().GetBool("interspersed")
|
||||
assert.Check(t, !value)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
registrytypes "github.com/docker/docker/api/types/registry"
|
||||
"github.com/docker/docker/registry"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/theupdateframework/notary/client"
|
||||
"github.com/theupdateframework/notary/passphrase"
|
||||
"github.com/theupdateframework/notary/trustpinning"
|
||||
|
@ -64,12 +63,12 @@ func TestNonOfficialTrustServer(t *testing.T) {
|
|||
|
||||
func TestAddTargetToAllSignableRolesError(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "notary-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever("password"), trustpinning.TrustPinConfig{})
|
||||
assert.NilError(t, err)
|
||||
target := client.Target{}
|
||||
err = AddTargetToAllSignableRoles(notaryRepo, &target)
|
||||
assert.Check(t, is.Error(err, "client is offline"))
|
||||
assert.Error(t, err, "client is offline")
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ func TestManifestCreateRefuseAmend(t *testing.T) {
|
|||
cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"})
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
err = cmd.Execute()
|
||||
assert.Check(t, is.Error(err, "refusing to amend an existing manifest list with no --amend flag"))
|
||||
assert.Error(t, err, "refusing to amend an existing manifest list with no --amend flag")
|
||||
}
|
||||
|
||||
// attempt to make a manifest list without valid images
|
||||
|
@ -112,5 +112,5 @@ func TestManifestCreateNoManifest(t *testing.T) {
|
|||
cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"})
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
err := cmd.Execute()
|
||||
assert.Check(t, is.Error(err, "No such image: example.com/alpine:3.0"))
|
||||
assert.Error(t, err, "No such image: example.com/alpine:3.0")
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/golden"
|
||||
"github.com/opencontainers/go-digest"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
@ -65,7 +65,7 @@ func TestInspectCommandLocalManifestNotFound(t *testing.T) {
|
|||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"})
|
||||
err := cmd.Execute()
|
||||
assert.Check(t, is.Error(err, "No such manifest: example.com/alpine:3.0"))
|
||||
assert.Error(t, err, "No such manifest: example.com/alpine:3.0")
|
||||
}
|
||||
|
||||
func TestInspectCommandNotFound(t *testing.T) {
|
||||
|
@ -87,7 +87,7 @@ func TestInspectCommandNotFound(t *testing.T) {
|
|||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs([]string{"example.com/alpine:3.0"})
|
||||
err := cmd.Execute()
|
||||
assert.Check(t, is.Error(err, "No such manifest: example.com/alpine:3.0"))
|
||||
assert.Error(t, err, "No such manifest: example.com/alpine:3.0")
|
||||
}
|
||||
|
||||
func TestInspectCommandLocalManifest(t *testing.T) {
|
||||
|
|
|
@ -66,5 +66,5 @@ func TestNetworkConnectWithFlags(t *testing.T) {
|
|||
cmd.Flags().Set("ip-range", "192.168.4.0/24")
|
||||
cmd.Flags().Set("gateway", "192.168.4.1/24")
|
||||
cmd.Flags().Set("subnet", "192.168.4.0/24")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
}
|
||||
|
|
|
@ -169,6 +169,6 @@ func TestNetworkCreateWithFlags(t *testing.T) {
|
|||
cmd.Flags().Set("ip-range", "192.168.4.0/24")
|
||||
cmd.Flags().Set("gateway", "192.168.4.1/24")
|
||||
cmd.Flags().Set("subnet", "192.168.4.0/24")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("banana", strings.TrimSpace(cli.OutBuffer().String())))
|
||||
}
|
||||
|
|
|
@ -58,6 +58,6 @@ func TestNetworkListWithFlags(t *testing.T) {
|
|||
cmd := newListCommand(cli)
|
||||
|
||||
cmd.Flags().Set("filter", "image.name=ubuntu")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, strings.TrimSpace(cli.OutBuffer().String()), "network-list.golden")
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ func TestNodeDemoteNoChange(t *testing.T) {
|
|||
},
|
||||
}))
|
||||
cmd.SetArgs([]string{"nodeID"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
}
|
||||
|
||||
func TestNodeDemoteMultipleNode(t *testing.T) {
|
||||
|
@ -80,5 +80,5 @@ func TestNodeDemoteMultipleNode(t *testing.T) {
|
|||
},
|
||||
}))
|
||||
cmd.SetArgs([]string{"nodeID1", "nodeID2"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ func TestNodeInspectPretty(t *testing.T) {
|
|||
cmd := newInspectCommand(cli)
|
||||
cmd.SetArgs([]string{"nodeID"})
|
||||
cmd.Flags().Set("pretty", "true")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("node-inspect-pretty.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) {
|
|||
})
|
||||
cmd := newListCommand(cli)
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, is.Error(cmd.Execute(), tc.expectedError))
|
||||
assert.Error(t, cmd.Execute(), tc.expectedError)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ func TestNodeList(t *testing.T) {
|
|||
})
|
||||
|
||||
cmd := newListCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "node-list-sort.golden")
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ func TestNodeListQuietShouldOnlyPrintIDs(t *testing.T) {
|
|||
})
|
||||
cmd := newListCommand(cli)
|
||||
cmd.Flags().Set("quiet", "true")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal(cli.OutBuffer().String(), "nodeID1\n"))
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ func TestNodeListDefaultFormatFromConfig(t *testing.T) {
|
|||
NodesFormat: "{{.ID}}: {{.Hostname}} {{.Status}}/{{.ManagerStatus}}",
|
||||
})
|
||||
cmd := newListCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "node-list-format-from-config.golden")
|
||||
}
|
||||
|
||||
|
@ -136,6 +136,6 @@ func TestNodeListFormat(t *testing.T) {
|
|||
})
|
||||
cmd := newListCommand(cli)
|
||||
cmd.Flags().Set("format", "{{.Hostname}}: {{.ManagerStatus}}")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "node-list-format-flag.golden")
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ func TestNodePromoteNoChange(t *testing.T) {
|
|||
},
|
||||
}))
|
||||
cmd.SetArgs([]string{"nodeID"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
}
|
||||
|
||||
func TestNodePromoteMultipleNode(t *testing.T) {
|
||||
|
@ -80,5 +80,5 @@ func TestNodePromoteMultipleNode(t *testing.T) {
|
|||
},
|
||||
}))
|
||||
cmd.SetArgs([]string{"nodeID1", "nodeID2"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import (
|
|||
// Import builders to get the builder function as package function
|
||||
. "github.com/docker/cli/internal/test/builders"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/golden"
|
||||
)
|
||||
|
||||
|
@ -61,7 +60,7 @@ func TestNodePsErrors(t *testing.T) {
|
|||
cmd.Flags().Set(key, value)
|
||||
}
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, is.Error(cmd.Execute(), tc.expectedError))
|
||||
assert.Error(t, cmd.Execute(), tc.expectedError)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,7 +122,7 @@ func TestNodePs(t *testing.T) {
|
|||
for key, value := range tc.flags {
|
||||
cmd.Flags().Set(key, value)
|
||||
}
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("node-ps.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,5 +40,5 @@ func TestNodeRemoveErrors(t *testing.T) {
|
|||
func TestNodeRemoveMultiple(t *testing.T) {
|
||||
cmd := newRemoveCommand(test.NewFakeCli(&fakeClient{}))
|
||||
cmd.SetArgs([]string{"nodeID1", "nodeID2"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
}
|
||||
|
|
|
@ -164,6 +164,6 @@ func TestNodeUpdate(t *testing.T) {
|
|||
for key, value := range tc.flags {
|
||||
cmd.Flags().Set(key, value)
|
||||
}
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,6 +109,6 @@ func TestCreatePlugin(t *testing.T) {
|
|||
|
||||
cmd := newCreateCommand(cli)
|
||||
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("plugin-foo\n", cli.OutBuffer().String()))
|
||||
}
|
||||
|
|
|
@ -53,6 +53,6 @@ func TestPluginDisable(t *testing.T) {
|
|||
})
|
||||
cmd := newDisableCommand(cli)
|
||||
cmd.SetArgs([]string{"plugin-foo"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("plugin-foo\n", cli.OutBuffer().String()))
|
||||
}
|
||||
|
|
|
@ -65,6 +65,6 @@ func TestPluginEnable(t *testing.T) {
|
|||
|
||||
cmd := newEnableCommand(cli)
|
||||
cmd.SetArgs([]string{"plugin-foo"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("plugin-foo\n", cli.OutBuffer().String()))
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ func TestRemove(t *testing.T) {
|
|||
})
|
||||
cmd := newRemoveCommand(cli)
|
||||
cmd.SetArgs([]string{"plugin-foo"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("plugin-foo\n", cli.OutBuffer().String()))
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ func TestRemoveWithForceOption(t *testing.T) {
|
|||
cmd := newRemoveCommand(cli)
|
||||
cmd.SetArgs([]string{"plugin-foo"})
|
||||
cmd.Flags().Set("force", "true")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, force)
|
||||
assert.Check(t, is.Equal("plugin-foo\n", cli.OutBuffer().String()))
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ func TestGetDefaultAuthConfig(t *testing.T) {
|
|||
assert.Check(t, err != nil)
|
||||
assert.Check(t, is.Equal(tc.expectedErr, err.Error()))
|
||||
} else {
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(tc.expectedAuthConfig, *authconfig))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ func TestSecretCreateErrors(t *testing.T) {
|
|||
func TestSecretCreateWithName(t *testing.T) {
|
||||
name := "foo"
|
||||
data, err := ioutil.ReadFile(filepath.Join("testdata", secretDataFile))
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
expected := swarm.SecretSpec{
|
||||
Annotations: swarm.Annotations{
|
||||
|
@ -75,7 +75,7 @@ func TestSecretCreateWithName(t *testing.T) {
|
|||
|
||||
cmd := newSecretCreateCommand(cli)
|
||||
cmd.SetArgs([]string{name, filepath.Join("testdata", secretDataFile)})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ func TestSecretCreateWithDriver(t *testing.T) {
|
|||
cmd := newSecretCreateCommand(cli)
|
||||
cmd.SetArgs([]string{name})
|
||||
cmd.Flags().Set("driver", expectedDriver.Name)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ func TestSecretCreateWithTemplatingDriver(t *testing.T) {
|
|||
cmd := newSecretCreateCommand(cli)
|
||||
cmd.SetArgs([]string{name})
|
||||
cmd.Flags().Set("template-driver", expectedDriver.Name)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
|
||||
}
|
||||
|
||||
|
@ -164,6 +164,6 @@ func TestSecretCreateWithLabels(t *testing.T) {
|
|||
cmd.SetArgs([]string{name, filepath.Join("testdata", secretDataFile)})
|
||||
cmd.Flags().Set("label", "lbl1=Label-foo")
|
||||
cmd.Flags().Set("label", "lbl2=Label-bar")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ func TestSecretInspectWithoutFormat(t *testing.T) {
|
|||
})
|
||||
cmd := newSecretInspectCommand(cli)
|
||||
cmd.SetArgs(tc.args)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("secret-inspect-without-format.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ func TestSecretInspectWithFormat(t *testing.T) {
|
|||
cmd := newSecretInspectCommand(cli)
|
||||
cmd.SetArgs(tc.args)
|
||||
cmd.Flags().Set("format", tc.format)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("secret-inspect-with-format.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ func TestSecretInspectPretty(t *testing.T) {
|
|||
cmd := newSecretInspectCommand(cli)
|
||||
cmd.SetArgs([]string{"secretID"})
|
||||
cmd.Flags().Set("pretty", "true")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("secret-inspect-pretty.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ func TestSecretList(t *testing.T) {
|
|||
},
|
||||
})
|
||||
cmd := newSecretListCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "secret-list-sort.golden")
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ func TestSecretListWithQuietOption(t *testing.T) {
|
|||
})
|
||||
cmd := newSecretListCommand(cli)
|
||||
cmd.Flags().Set("quiet", "true")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "secret-list-with-quiet-option.golden")
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ func TestSecretListWithConfigFormat(t *testing.T) {
|
|||
SecretFormat: "{{ .Name }} {{ .Labels }}",
|
||||
})
|
||||
cmd := newSecretListCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "secret-list-with-config-format.golden")
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ func TestSecretListWithFormat(t *testing.T) {
|
|||
})
|
||||
cmd := newSecretListCommand(cli)
|
||||
cmd.Flags().Set("format", "{{ .Name }} {{ .Labels }}")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "secret-list-with-format.golden")
|
||||
}
|
||||
|
||||
|
@ -155,6 +155,6 @@ func TestSecretListWithFilter(t *testing.T) {
|
|||
cmd := newSecretListCommand(cli)
|
||||
cmd.Flags().Set("filter", "name=foo")
|
||||
cmd.Flags().Set("filter", "label=lbl1=Label-bar")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "secret-list-with-filter.golden")
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ func TestSecretRemoveWithName(t *testing.T) {
|
|||
})
|
||||
cmd := newSecretRemoveCommand(cli)
|
||||
cmd.SetArgs(names)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.DeepEqual(names, strings.Split(strings.TrimSpace(cli.OutBuffer().String()), "\n")))
|
||||
assert.Check(t, is.DeepEqual(names, removedSecrets))
|
||||
}
|
||||
|
@ -74,6 +74,6 @@ func TestSecretRemoveContinueAfterError(t *testing.T) {
|
|||
cmd := newSecretRemoveCommand(cli)
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs(names)
|
||||
assert.Check(t, is.Error(cmd.Execute(), "error removing secret: foo"))
|
||||
assert.Error(t, cmd.Execute(), "error removing secret: foo")
|
||||
assert.Check(t, is.DeepEqual(names, removedSecrets))
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@ func TestValidateSingleGenericResource(t *testing.T) {
|
|||
|
||||
for _, v := range correct {
|
||||
_, err := ValidateSingleGenericResource(v)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,6 @@ func TestServiceListOrder(t *testing.T) {
|
|||
})
|
||||
cmd := newListCommand(cli)
|
||||
cmd.Flags().Set("format", "{{.Name}}")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "service-list-sort.golden")
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestMemBytesString(t *testing.T) {
|
|||
|
||||
func TestMemBytesSetAndValue(t *testing.T) {
|
||||
var mem opts.MemBytes
|
||||
assert.Check(t, mem.Set("5kb"))
|
||||
assert.NilError(t, mem.Set("5kb"))
|
||||
assert.Check(t, is.Equal(int64(5120), mem.Value()))
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ func TestNanoCPUsString(t *testing.T) {
|
|||
|
||||
func TestNanoCPUsSetAndValue(t *testing.T) {
|
||||
var cpus opts.NanoCPUs
|
||||
assert.Check(t, cpus.Set("0.35"))
|
||||
assert.NilError(t, cpus.Set("0.35"))
|
||||
assert.Check(t, is.Equal(int64(350000000), cpus.Value()))
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ func TestUint64OptString(t *testing.T) {
|
|||
|
||||
func TestUint64OptSetAndValue(t *testing.T) {
|
||||
var opt Uint64Opt
|
||||
assert.Check(t, opt.Set("14445"))
|
||||
assert.NilError(t, opt.Set("14445"))
|
||||
assert.Check(t, is.Equal(uint64(14445), *opt.Value()))
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ func TestHealthCheckOptionsToHealthConfig(t *testing.T) {
|
|||
retries: 10,
|
||||
}
|
||||
config, err := opt.toHealthConfig()
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(&container.HealthConfig{
|
||||
Test: []string{"CMD-SHELL", "curl"},
|
||||
Interval: time.Second,
|
||||
|
@ -76,7 +76,7 @@ func TestHealthCheckOptionsToHealthConfigNoHealthcheck(t *testing.T) {
|
|||
noHealthcheck: true,
|
||||
}
|
||||
config, err := opt.toHealthConfig()
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(&container.HealthConfig{
|
||||
Test: []string{"NONE"},
|
||||
}, config))
|
||||
|
@ -88,7 +88,7 @@ func TestHealthCheckOptionsToHealthConfigConflict(t *testing.T) {
|
|||
noHealthcheck: true,
|
||||
}
|
||||
_, err := opt.toHealthConfig()
|
||||
assert.Check(t, is.Error(err, "--no-healthcheck conflicts with --health-* options"))
|
||||
assert.Error(t, err, "--no-healthcheck conflicts with --health-* options")
|
||||
}
|
||||
|
||||
func TestResourceOptionsToResourceRequirements(t *testing.T) {
|
||||
|
@ -123,7 +123,7 @@ func TestResourceOptionsToResourceRequirements(t *testing.T) {
|
|||
|
||||
for _, opt := range correctOptions {
|
||||
r, err := opt.ToResourceRequirements()
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Len(r.Reservations.GenericResources, len(opt.resGenericResources)))
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ func TestCreateFilterWithAmbiguousIDPrefixError(t *testing.T) {
|
|||
filter: opts.NewFilterOpt(),
|
||||
}
|
||||
_, _, err := createFilter(context.Background(), client, options)
|
||||
assert.Check(t, is.Error(err, "multiple services found with provided prefix: aaa"))
|
||||
assert.Error(t, err, "multiple services found with provided prefix: aaa")
|
||||
}
|
||||
|
||||
func TestCreateFilterNoneFound(t *testing.T) {
|
||||
|
@ -70,7 +70,7 @@ func TestCreateFilterNoneFound(t *testing.T) {
|
|||
filter: opts.NewFilterOpt(),
|
||||
}
|
||||
_, _, err := createFilter(context.Background(), client, options)
|
||||
assert.Check(t, is.Error(err, "no such service: foo\nno such service: notfound"))
|
||||
assert.Error(t, err, "no such service: foo\nno such service: notfound")
|
||||
}
|
||||
|
||||
func TestRunPSWarnsOnNotFound(t *testing.T) {
|
||||
|
@ -89,7 +89,7 @@ func TestRunPSWarnsOnNotFound(t *testing.T) {
|
|||
format: "{{.ID}}",
|
||||
}
|
||||
err := runPS(cli, options)
|
||||
assert.Check(t, is.Error(err, "no such service: bar"))
|
||||
assert.Error(t, err, "no such service: bar")
|
||||
}
|
||||
|
||||
func TestRunPSQuiet(t *testing.T) {
|
||||
|
|
|
@ -50,7 +50,7 @@ func TestRollback(t *testing.T) {
|
|||
cmd.SetArgs(tc.args)
|
||||
cmd.Flags().Set("quiet", "true")
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal(strings.TrimSpace(cli.ErrBuffer().String()), tc.expectedDockerCliErr))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ func TestUpdatePorts(t *testing.T) {
|
|||
}
|
||||
|
||||
err := updatePorts(flags, &portConfigs)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, is.Len(portConfigs, 2))
|
||||
// Do a sort to have the order (might have changed by map)
|
||||
targetPorts := []int{int(portConfigs[0].TargetPort), int(portConfigs[1].TargetPort)}
|
||||
|
@ -268,7 +268,7 @@ func TestUpdatePortsDuplicate(t *testing.T) {
|
|||
}
|
||||
|
||||
err := updatePorts(flags, &portConfigs)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, is.Len(portConfigs, 1))
|
||||
assert.Check(t, is.Equal(uint32(80), portConfigs[0].TargetPort))
|
||||
}
|
||||
|
@ -344,9 +344,9 @@ func TestUpdateHealthcheckTable(t *testing.T) {
|
|||
}
|
||||
err := updateHealthcheck(flags, cspec)
|
||||
if c.err != "" {
|
||||
assert.Check(t, is.Error(err, c.err))
|
||||
assert.Error(t, err, c.err)
|
||||
} else {
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
if !reflect.DeepEqual(cspec.Healthcheck, c.expected) {
|
||||
t.Errorf("incorrect result for test %d, expected health config:\n\t%#v\ngot:\n\t%#v", i, c.expected, cspec.Healthcheck)
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ func TestUpdateHosts(t *testing.T) {
|
|||
expected := []string{"1.2.3.4 example.com", "4.3.2.1 example.org", "2001:db8:abc8::1 ipv6.net"}
|
||||
|
||||
err := updateHosts(flags, &hosts)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(expected, hosts))
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ func TestUpdateHostsPreservesOrder(t *testing.T) {
|
|||
|
||||
hosts := []string{}
|
||||
err := updateHosts(flags, &hosts)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual([]string{"127.0.0.2 foobar", "127.0.0.1 foobar", "127.0.0.3 foobar"}, hosts))
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,7 @@ func TestUpdatePortsRmWithProtocol(t *testing.T) {
|
|||
}
|
||||
|
||||
err := updatePorts(flags, &portConfigs)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, is.Len(portConfigs, 2))
|
||||
assert.Check(t, is.Equal(uint32(81), portConfigs[0].TargetPort))
|
||||
assert.Check(t, is.Equal(uint32(82), portConfigs[1].TargetPort))
|
||||
|
@ -460,7 +460,7 @@ func TestUpdateSecretUpdateInPlace(t *testing.T) {
|
|||
|
||||
updatedSecrets, err := getUpdatedSecrets(apiClient, flags, secrets)
|
||||
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, is.Len(updatedSecrets, 1))
|
||||
assert.Check(t, is.Equal("tn9qiblgnuuut11eufquw5dev", updatedSecrets[0].SecretID))
|
||||
assert.Check(t, is.Equal("foo", updatedSecrets[0].SecretName))
|
||||
|
@ -626,21 +626,21 @@ func TestUpdateNetworks(t *testing.T) {
|
|||
err = flags.Set(flagNetworkAdd, "aaa-network")
|
||||
assert.NilError(t, err)
|
||||
err = updateService(ctx, client, flags, &svc)
|
||||
assert.Check(t, is.Error(err, "service is already attached to network aaa-network"))
|
||||
assert.Error(t, err, "service is already attached to network aaa-network")
|
||||
assert.Check(t, is.DeepEqual([]swarm.NetworkAttachmentConfig{{Target: "id555"}, {Target: "id999"}}, svc.TaskTemplate.Networks))
|
||||
|
||||
flags = newUpdateCommand(nil).Flags()
|
||||
err = flags.Set(flagNetworkAdd, "id555")
|
||||
assert.NilError(t, err)
|
||||
err = updateService(ctx, client, flags, &svc)
|
||||
assert.Check(t, is.Error(err, "service is already attached to network id555"))
|
||||
assert.Error(t, err, "service is already attached to network id555")
|
||||
assert.Check(t, is.DeepEqual([]swarm.NetworkAttachmentConfig{{Target: "id555"}, {Target: "id999"}}, svc.TaskTemplate.Networks))
|
||||
|
||||
flags = newUpdateCommand(nil).Flags()
|
||||
err = flags.Set(flagNetworkRemove, "id999")
|
||||
assert.NilError(t, err)
|
||||
err = updateService(ctx, client, flags, &svc)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual([]swarm.NetworkAttachmentConfig{{Target: "id555"}}, svc.TaskTemplate.Networks))
|
||||
|
||||
flags = newUpdateCommand(nil).Flags()
|
||||
|
@ -649,6 +649,6 @@ func TestUpdateNetworks(t *testing.T) {
|
|||
err = flags.Set(flagNetworkRemove, "aaa-network")
|
||||
assert.NilError(t, err)
|
||||
err = updateService(ctx, client, flags, &svc)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual([]swarm.NetworkAttachmentConfig{{Target: "id999"}}, svc.TaskTemplate.Networks))
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ func TestListWithFormat(t *testing.T) {
|
|||
})
|
||||
cmd := newListCommand(cli)
|
||||
cmd.Flags().Set("format", "{{ .Name }}")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "stack-list-with-format.golden")
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ func TestListWithoutFormat(t *testing.T) {
|
|||
},
|
||||
})
|
||||
cmd := newListCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "stack-list-without-format.golden")
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ func TestListOrder(t *testing.T) {
|
|||
},
|
||||
})
|
||||
cmd := newListCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), uc.golden)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ func TestStackPsEmptyStack(t *testing.T) {
|
|||
cmd.SetArgs([]string{"foo"})
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
|
||||
assert.Check(t, is.Error(cmd.Execute(), "nothing found in stack: foo"))
|
||||
assert.Error(t, cmd.Execute(), "nothing found in stack: foo")
|
||||
assert.Check(t, is.Equal("", fakeCli.OutBuffer().String()))
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ func TestStackPsWithQuietOption(t *testing.T) {
|
|||
cmd := newPsCommand(cli)
|
||||
cmd.SetArgs([]string{"foo"})
|
||||
cmd.Flags().Set("quiet", "true")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "stack-ps-with-quiet-option.golden")
|
||||
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ func TestStackPsWithNoTruncOption(t *testing.T) {
|
|||
cmd.SetArgs([]string{"foo"})
|
||||
cmd.Flags().Set("no-trunc", "true")
|
||||
cmd.Flags().Set("format", "{{ .ID }}")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "stack-ps-with-no-trunc-option.golden")
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ func TestStackPsWithNoResolveOption(t *testing.T) {
|
|||
cmd.SetArgs([]string{"foo"})
|
||||
cmd.Flags().Set("no-resolve", "true")
|
||||
cmd.Flags().Set("format", "{{ .Node }}")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "stack-ps-with-no-resolve-option.golden")
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ func TestStackPsWithFormat(t *testing.T) {
|
|||
cmd := newPsCommand(cli)
|
||||
cmd.SetArgs([]string{"foo"})
|
||||
cmd.Flags().Set("format", "{{ .Name }}")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "stack-ps-with-format.golden")
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ func TestStackPsWithConfigFormat(t *testing.T) {
|
|||
})
|
||||
cmd := newPsCommand(cli)
|
||||
cmd.SetArgs([]string{"foo"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "stack-ps-with-config-format.golden")
|
||||
}
|
||||
|
||||
|
@ -158,6 +158,6 @@ func TestStackPsWithoutFormat(t *testing.T) {
|
|||
})
|
||||
cmd := newPsCommand(cli)
|
||||
cmd.SetArgs([]string{"foo"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "stack-ps-without-format.golden")
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ func TestRemoveStackVersion124DoesNotRemoveConfigsOrSecrets(t *testing.T) {
|
|||
cmd := newRemoveCommand(test.NewFakeCli(client))
|
||||
cmd.SetArgs([]string{"foo", "bar"})
|
||||
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.DeepEqual(buildObjectIDs(client.services), client.removedServices))
|
||||
assert.Check(t, is.DeepEqual(buildObjectIDs(client.networks), client.removedNetworks))
|
||||
assert.Check(t, is.Len(client.removedSecrets, 0))
|
||||
|
@ -58,7 +58,7 @@ func TestRemoveStackVersion125DoesNotRemoveConfigs(t *testing.T) {
|
|||
cmd := newRemoveCommand(test.NewFakeCli(client))
|
||||
cmd.SetArgs([]string{"foo", "bar"})
|
||||
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.DeepEqual(buildObjectIDs(client.services), client.removedServices))
|
||||
assert.Check(t, is.DeepEqual(buildObjectIDs(client.networks), client.removedNetworks))
|
||||
assert.Check(t, is.DeepEqual(buildObjectIDs(client.secrets), client.removedSecrets))
|
||||
|
@ -70,7 +70,7 @@ func TestRemoveStackVersion130RemovesEverything(t *testing.T) {
|
|||
cmd := newRemoveCommand(test.NewFakeCli(client))
|
||||
cmd.SetArgs([]string{"foo", "bar"})
|
||||
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.DeepEqual(buildObjectIDs(client.services), client.removedServices))
|
||||
assert.Check(t, is.DeepEqual(buildObjectIDs(client.networks), client.removedNetworks))
|
||||
assert.Check(t, is.DeepEqual(buildObjectIDs(client.secrets), client.removedSecrets))
|
||||
|
@ -101,7 +101,7 @@ func TestRemoveStackSkipEmpty(t *testing.T) {
|
|||
cmd := newRemoveCommand(fakeCli)
|
||||
cmd.SetArgs([]string{"foo", "bar"})
|
||||
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
expectedList := []string{"Removing service bar_service1",
|
||||
"Removing service bar_service2",
|
||||
"Removing secret bar_secret1",
|
||||
|
@ -150,7 +150,7 @@ func TestRemoveContinueAfterError(t *testing.T) {
|
|||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs([]string{"foo", "bar"})
|
||||
|
||||
assert.Check(t, is.Error(cmd.Execute(), "Failed to remove some resources from stack: foo"))
|
||||
assert.Error(t, cmd.Execute(), "Failed to remove some resources from stack: foo")
|
||||
assert.Check(t, is.DeepEqual(allServiceIDs, removedServices))
|
||||
assert.Check(t, is.DeepEqual(allNetworkIDs, cli.removedNetworks))
|
||||
assert.Check(t, is.DeepEqual(allSecretIDs, cli.removedSecrets))
|
||||
|
|
|
@ -88,7 +88,7 @@ func TestStackServicesEmptyServiceList(t *testing.T) {
|
|||
})
|
||||
cmd := newServicesCommand(fakeCli)
|
||||
cmd.SetArgs([]string{"foo"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("", fakeCli.OutBuffer().String()))
|
||||
assert.Check(t, is.Equal("Nothing found in stack: foo\n", fakeCli.ErrBuffer().String()))
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ func TestStackServicesWithQuietOption(t *testing.T) {
|
|||
cmd := newServicesCommand(cli)
|
||||
cmd.Flags().Set("quiet", "true")
|
||||
cmd.SetArgs([]string{"foo"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "stack-services-with-quiet-option.golden")
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ func TestStackServicesWithFormat(t *testing.T) {
|
|||
cmd := newServicesCommand(cli)
|
||||
cmd.SetArgs([]string{"foo"})
|
||||
cmd.Flags().Set("format", "{{ .Name }}")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "stack-services-with-format.golden")
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ func TestStackServicesWithConfigFormat(t *testing.T) {
|
|||
})
|
||||
cmd := newServicesCommand(cli)
|
||||
cmd.SetArgs([]string{"foo"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "stack-services-with-config-format.golden")
|
||||
}
|
||||
|
||||
|
@ -157,6 +157,6 @@ func TestStackServicesWithoutFormat(t *testing.T) {
|
|||
})
|
||||
cmd := newServicesCommand(cli)
|
||||
cmd.SetArgs([]string{"foo"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "stack-services-without-format.golden")
|
||||
}
|
||||
|
|
|
@ -45,6 +45,6 @@ func TestLoadBundlefile(t *testing.T) {
|
|||
path := filepath.Join("testdata", "bundlefile_with_two_services.dab")
|
||||
bundleFile, err := loadBundlefile(buf, namespace, path)
|
||||
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(len(bundleFile.Services), 2))
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ func TestValidateExternalNetworks(t *testing.T) {
|
|||
networks := []string{testcase.network}
|
||||
err := validateExternalNetworks(context.Background(), fakeClient, networks)
|
||||
if testcase.expectedMsg == "" {
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
} else {
|
||||
assert.ErrorContains(t, err, testcase.expectedMsg)
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ func TestServiceUpdateResolveImageChanged(t *testing.T) {
|
|||
},
|
||||
}
|
||||
err := deployServices(ctx, client, spec, namespace, false, ResolveImageChanged)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(testcase.expectedQueryRegistry, receivedOptions.QueryRegistry))
|
||||
assert.Check(t, is.Equal(testcase.expectedImage, receivedService.TaskTemplate.ContainerSpec.Image))
|
||||
|
||||
|
|
|
@ -34,13 +34,13 @@ func swarmSpecWithFullCAConfig() *swarm.Spec {
|
|||
func TestDisplayTrustRootNoRoot(t *testing.T) {
|
||||
buffer := new(bytes.Buffer)
|
||||
err := displayTrustRoot(buffer, swarm.Swarm{})
|
||||
assert.Check(t, is.Error(err, "No CA information available"))
|
||||
assert.Error(t, err, "No CA information available")
|
||||
}
|
||||
|
||||
func TestDisplayTrustRootInvalidFlags(t *testing.T) {
|
||||
// we need an actual PEMfile to test
|
||||
tmpfile, err := ioutil.TempFile("", "pemfile")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.Remove(tmpfile.Name())
|
||||
tmpfile.Write([]byte(`
|
||||
-----BEGIN CERTIFICATE-----
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/golden"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -75,7 +74,7 @@ func TestSwarmInitErrorOnAPIFailure(t *testing.T) {
|
|||
cmd.Flags().Set(key, value)
|
||||
}
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, is.Error(cmd.Execute(), tc.expectedError))
|
||||
assert.Error(t, cmd.Execute(), tc.expectedError)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +119,7 @@ func TestSwarmInit(t *testing.T) {
|
|||
for key, value := range tc.flags {
|
||||
cmd.Flags().Set(key, value)
|
||||
}
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("init-%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ func TestSwarmJoin(t *testing.T) {
|
|||
})
|
||||
cmd := newJoinCommand(cli)
|
||||
cmd.SetArgs([]string{"remote"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal(strings.TrimSpace(cli.OutBuffer().String()), tc.expected))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ func TestSwarmJoinToken(t *testing.T) {
|
|||
for key, value := range tc.flags {
|
||||
cmd.Flags().Set(key, value)
|
||||
}
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("jointoken-%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,6 @@ func TestSwarmLeaveErrors(t *testing.T) {
|
|||
func TestSwarmLeave(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{})
|
||||
cmd := newLeaveCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("Node left the swarm.", strings.TrimSpace(cli.OutBuffer().String())))
|
||||
}
|
||||
|
|
|
@ -10,31 +10,31 @@ import (
|
|||
func TestNodeAddrOptionSetHostAndPort(t *testing.T) {
|
||||
opt := NewNodeAddrOption("old:123")
|
||||
addr := "newhost:5555"
|
||||
assert.Check(t, opt.Set(addr))
|
||||
assert.NilError(t, opt.Set(addr))
|
||||
assert.Check(t, is.Equal(addr, opt.Value()))
|
||||
}
|
||||
|
||||
func TestNodeAddrOptionSetHostOnly(t *testing.T) {
|
||||
opt := NewListenAddrOption()
|
||||
assert.Check(t, opt.Set("newhost"))
|
||||
assert.NilError(t, opt.Set("newhost"))
|
||||
assert.Check(t, is.Equal("newhost:2377", opt.Value()))
|
||||
}
|
||||
|
||||
func TestNodeAddrOptionSetHostOnlyIPv6(t *testing.T) {
|
||||
opt := NewListenAddrOption()
|
||||
assert.Check(t, opt.Set("::1"))
|
||||
assert.NilError(t, opt.Set("::1"))
|
||||
assert.Check(t, is.Equal("[::1]:2377", opt.Value()))
|
||||
}
|
||||
|
||||
func TestNodeAddrOptionSetPortOnly(t *testing.T) {
|
||||
opt := NewListenAddrOption()
|
||||
assert.Check(t, opt.Set(":4545"))
|
||||
assert.NilError(t, opt.Set(":4545"))
|
||||
assert.Check(t, is.Equal("0.0.0.0:4545", opt.Value()))
|
||||
}
|
||||
|
||||
func TestNodeAddrOptionSetInvalidFormat(t *testing.T) {
|
||||
opt := NewListenAddrOption()
|
||||
assert.Check(t, is.Error(opt.Set("http://localhost:4545"), "Invalid proto, expected tcp: http://localhost:4545"))
|
||||
assert.Error(t, opt.Set("http://localhost:4545"), "Invalid proto, expected tcp: http://localhost:4545")
|
||||
}
|
||||
|
||||
func TestExternalCAOptionErrors(t *testing.T) {
|
||||
|
@ -65,7 +65,7 @@ func TestExternalCAOptionErrors(t *testing.T) {
|
|||
}
|
||||
for _, tc := range testCases {
|
||||
opt := &ExternalCAOption{}
|
||||
assert.Check(t, is.Error(opt.Set(tc.externalCA), tc.expectedError))
|
||||
assert.Error(t, opt.Set(tc.externalCA), tc.expectedError)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,15 +97,15 @@ func TestExternalCAOption(t *testing.T) {
|
|||
}
|
||||
for _, tc := range testCases {
|
||||
opt := &ExternalCAOption{}
|
||||
assert.Check(t, opt.Set(tc.externalCA))
|
||||
assert.NilError(t, opt.Set(tc.externalCA))
|
||||
assert.Check(t, is.Equal(tc.expected, opt.String()))
|
||||
}
|
||||
}
|
||||
|
||||
func TestExternalCAOptionMultiple(t *testing.T) {
|
||||
opt := &ExternalCAOption{}
|
||||
assert.Check(t, opt.Set("protocol=cfssl,url=https://example.com"))
|
||||
assert.Check(t, opt.Set("protocol=CFSSL,url=anything"))
|
||||
assert.NilError(t, opt.Set("protocol=cfssl,url=https://example.com"))
|
||||
assert.NilError(t, opt.Set("protocol=CFSSL,url=anything"))
|
||||
assert.Check(t, is.Len(opt.Value(), 2))
|
||||
assert.Check(t, is.Equal("cfssl: https://example.com, cfssl: anything", opt.String()))
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ func TestSwarmUnlockKey(t *testing.T) {
|
|||
for key, value := range tc.flags {
|
||||
cmd.Flags().Set(key, value)
|
||||
}
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("unlockkeys-%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,5 +94,5 @@ func TestSwarmUnlock(t *testing.T) {
|
|||
})
|
||||
dockerCli.SetIn(command.NewInStream(ioutil.NopCloser(strings.NewReader(input))))
|
||||
cmd := newUnlockCommand(dockerCli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ func TestSwarmUpdate(t *testing.T) {
|
|||
cmd.Flags().Set(key, value)
|
||||
}
|
||||
cmd.SetOutput(cli.OutBuffer())
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("update-%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
func TestPrunePromptPre131DoesNotIncludeBuildCache(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{version: "1.30"})
|
||||
cmd := newPruneCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
expected := `WARNING! This will remove:
|
||||
- all stopped containers
|
||||
- all networks not used by at least one container
|
||||
|
|
|
@ -24,7 +24,7 @@ func TestTaskPrintWithQuietOption(t *testing.T) {
|
|||
cli := test.NewFakeCli(apiClient)
|
||||
tasks := []swarm.Task{*Task(TaskID("id-foo"))}
|
||||
err := Print(context.Background(), cli, tasks, idresolver.New(apiClient, noResolve), trunc, quiet, formatter.TableFormatKey)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
golden.Assert(t, cli.OutBuffer().String(), "task-print-with-quiet-option.golden")
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ func TestTaskPrintWithNoTruncOption(t *testing.T) {
|
|||
*Task(TaskID("id-foo-yov6omdek8fg3k5stosyp2m50")),
|
||||
}
|
||||
err := Print(context.Background(), cli, tasks, idresolver.New(apiClient, noResolve), trunc, quiet, "{{ .ID }}")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
golden.Assert(t, cli.OutBuffer().String(), "task-print-with-no-trunc-option.golden")
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ func TestTaskPrintWithGlobalService(t *testing.T) {
|
|||
*Task(TaskServiceID("service-id-foo"), TaskNodeID("node-id-bar"), TaskSlot(0)),
|
||||
}
|
||||
err := Print(context.Background(), cli, tasks, idresolver.New(apiClient, noResolve), trunc, quiet, "{{ .Name }}")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
golden.Assert(t, cli.OutBuffer().String(), "task-print-with-global-service.golden")
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ func TestTaskPrintWithReplicatedService(t *testing.T) {
|
|||
*Task(TaskServiceID("service-id-foo"), TaskSlot(1)),
|
||||
}
|
||||
err := Print(context.Background(), cli, tasks, idresolver.New(apiClient, noResolve), trunc, quiet, "{{ .Name }}")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
golden.Assert(t, cli.OutBuffer().String(), "task-print-with-replicated-service.golden")
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ func TestTaskPrintWithIndentation(t *testing.T) {
|
|||
),
|
||||
}
|
||||
err := Print(context.Background(), cli, tasks, idresolver.New(apiClient, noResolve), trunc, quiet, formatter.TableFormatKey)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
golden.Assert(t, cli.OutBuffer().String(), "task-print-with-indentation.golden")
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,6 @@ func TestTaskPrintWithResolution(t *testing.T) {
|
|||
*Task(TaskServiceID("service-id-foo"), TaskSlot(1)),
|
||||
}
|
||||
err := Print(context.Background(), cli, tasks, idresolver.New(apiClient, noResolve), trunc, quiet, "{{ .Name }} {{ .Node }}")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
golden.Assert(t, cli.OutBuffer().String(), "task-print-with-resolution.golden")
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/theupdateframework/notary/client"
|
||||
"github.com/theupdateframework/notary/passphrase"
|
||||
"github.com/theupdateframework/notary/trustpinning"
|
||||
|
@ -14,12 +13,12 @@ import (
|
|||
|
||||
func TestGetOrGenerateNotaryKeyAndInitRepo(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "notary-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = getOrGenerateRootKeyAndInitRepo(notaryRepo)
|
||||
assert.Check(t, is.Error(err, "client is offline"))
|
||||
assert.Error(t, err, "client is offline")
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ func TestTrustInspectCommandEmptyNotaryRepo(t *testing.T) {
|
|||
cmd := newInspectCommand(cli)
|
||||
cmd.SetArgs([]string{"reg/img:unsigned-tag"})
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "trust-inspect-empty-repo.golden")
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ func TestTrustInspectCommandFullRepoWithoutSigners(t *testing.T) {
|
|||
cli.SetNotaryClient(getLoadedWithNoSignersNotaryRepository)
|
||||
cmd := newInspectCommand(cli)
|
||||
cmd.SetArgs([]string{"signed-repo"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "trust-inspect-full-repo-no-signers.golden")
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ func TestTrustInspectCommandOneTagWithoutSigners(t *testing.T) {
|
|||
cli.SetNotaryClient(getLoadedWithNoSignersNotaryRepository)
|
||||
cmd := newInspectCommand(cli)
|
||||
cmd.SetArgs([]string{"signed-repo:green"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "trust-inspect-one-tag-no-signers.golden")
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ func TestTrustInspectCommandFullRepoWithSigners(t *testing.T) {
|
|||
cli.SetNotaryClient(getLoadedNotaryRepository)
|
||||
cmd := newInspectCommand(cli)
|
||||
cmd.SetArgs([]string{"signed-repo"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "trust-inspect-full-repo-with-signers.golden")
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ func TestTrustInspectCommandMultipleFullReposWithSigners(t *testing.T) {
|
|||
cli.SetNotaryClient(getLoadedNotaryRepository)
|
||||
cmd := newInspectCommand(cli)
|
||||
cmd.SetArgs([]string{"signed-repo", "signed-repo"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "trust-inspect-multiple-repos-with-signers.golden")
|
||||
}
|
||||
|
||||
|
@ -129,6 +129,6 @@ func TestTrustInspectCommandUnsignedTagInSignedRepo(t *testing.T) {
|
|||
cli.SetNotaryClient(getLoadedNotaryRepository)
|
||||
cmd := newInspectCommand(cli)
|
||||
cmd.SetArgs([]string{"signed-repo:unsigned"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "trust-inspect-unsigned-tag-with-signers.golden")
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func TestTrustKeyGenerateErrors(t *testing.T) {
|
|||
}
|
||||
|
||||
tmpDir, err := ioutil.TempDir("", "docker-key-generate-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
config.SetDir(tmpDir)
|
||||
|
||||
|
@ -51,11 +51,11 @@ func TestTrustKeyGenerateErrors(t *testing.T) {
|
|||
|
||||
func TestGenerateKeySuccess(t *testing.T) {
|
||||
pubKeyCWD, err := ioutil.TempDir("", "pub-keys-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(pubKeyCWD)
|
||||
|
||||
privKeyStorageDir, err := ioutil.TempDir("", "priv-keys-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(privKeyStorageDir)
|
||||
|
||||
passwd := "password"
|
||||
|
@ -63,10 +63,10 @@ func TestGenerateKeySuccess(t *testing.T) {
|
|||
// generate a single key
|
||||
keyName := "alice"
|
||||
privKeyFileStore, err := trustmanager.NewKeyFileStore(privKeyStorageDir, cannedPasswordRetriever)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
pubKeyPEM, err := generateKeyAndOutputPubPEM(keyName, privKeyFileStore)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
assert.Check(t, is.Equal(keyName, pubKeyPEM.Headers["role"]))
|
||||
// the default GUN is empty
|
||||
|
@ -77,10 +77,10 @@ func TestGenerateKeySuccess(t *testing.T) {
|
|||
// check that an appropriate ~/<trust_dir>/private/<key_id>.key file exists
|
||||
expectedPrivKeyDir := filepath.Join(privKeyStorageDir, notary.PrivDir)
|
||||
_, err = os.Stat(expectedPrivKeyDir)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
keyFiles, err := ioutil.ReadDir(expectedPrivKeyDir)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Len(keyFiles, 1))
|
||||
privKeyFilePath := filepath.Join(expectedPrivKeyDir, keyFiles[0].Name())
|
||||
|
||||
|
@ -96,28 +96,28 @@ func TestGenerateKeySuccess(t *testing.T) {
|
|||
assert.Check(t, is.Equal("ENCRYPTED PRIVATE KEY", privKeyPEM.Type))
|
||||
// check that the passphrase matches
|
||||
_, err = tufutils.ParsePKCS8ToTufKey(privKeyPEM.Bytes, []byte(passwd))
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
// check that the public key exists at the correct path if we use the helper:
|
||||
returnedPath, err := writePubKeyPEMToDir(pubKeyPEM, keyName, pubKeyCWD)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
expectedPubKeyPath := filepath.Join(pubKeyCWD, keyName+".pub")
|
||||
assert.Check(t, is.Equal(returnedPath, expectedPubKeyPath))
|
||||
_, err = os.Stat(expectedPubKeyPath)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
// check that the public key is the only file output in CWD
|
||||
cwdKeyFiles, err := ioutil.ReadDir(pubKeyCWD)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Len(cwdKeyFiles, 1))
|
||||
}
|
||||
|
||||
func TestValidateKeyArgs(t *testing.T) {
|
||||
pubKeyCWD, err := ioutil.TempDir("", "pub-keys-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(pubKeyCWD)
|
||||
|
||||
err = validateKeyArgs("a", pubKeyCWD)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = validateKeyArgs("a/b", pubKeyCWD)
|
||||
assert.Error(t, err, "key name \"a/b\" must start with lowercase alphanumeric characters and can include \"-\" or \"_\" after the first character")
|
||||
|
@ -125,7 +125,7 @@ func TestValidateKeyArgs(t *testing.T) {
|
|||
err = validateKeyArgs("-", pubKeyCWD)
|
||||
assert.Error(t, err, "key name \"-\" must start with lowercase alphanumeric characters and can include \"-\" or \"_\" after the first character")
|
||||
|
||||
assert.Check(t, ioutil.WriteFile(filepath.Join(pubKeyCWD, "a.pub"), []byte("abc"), notary.PrivExecPerms))
|
||||
assert.NilError(t, ioutil.WriteFile(filepath.Join(pubKeyCWD, "a.pub"), []byte("abc"), notary.PrivExecPerms))
|
||||
err = validateKeyArgs("a", pubKeyCWD)
|
||||
assert.Error(t, err, fmt.Sprintf("public key file already exists: \"%s/a.pub\"", pubKeyCWD))
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ func TestTrustKeyLoadErrors(t *testing.T) {
|
|||
},
|
||||
}
|
||||
tmpDir, err := ioutil.TempDir("", "docker-key-load-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
config.SetDir(tmpDir)
|
||||
|
||||
|
@ -118,24 +118,24 @@ func TestLoadKeyFromPath(t *testing.T) {
|
|||
|
||||
func testLoadKeyFromPath(t *testing.T, privKeyID string, privKeyFixture []byte) {
|
||||
privKeyDir, err := ioutil.TempDir("", "key-load-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(privKeyDir)
|
||||
privKeyFilepath := filepath.Join(privKeyDir, "privkey.pem")
|
||||
assert.Check(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, notary.PrivNoExecPerms))
|
||||
assert.NilError(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, notary.PrivNoExecPerms))
|
||||
|
||||
keyStorageDir, err := ioutil.TempDir("", "loaded-keys-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(keyStorageDir)
|
||||
|
||||
passwd := "password"
|
||||
cannedPasswordRetriever := passphrase.ConstantRetriever(passwd)
|
||||
keyFileStore, err := storage.NewPrivateKeyFileStorage(keyStorageDir, notary.KeyExtension)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
privKeyImporters := []trustmanager.Importer{keyFileStore}
|
||||
|
||||
// get the privKeyBytes
|
||||
privKeyBytes, err := getPrivKeyBytesFromPath(privKeyFilepath)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
// import the key to our keyStorageDir
|
||||
assert.Check(t, loadPrivKeyBytesToStore(privKeyBytes, privKeyImporters, privKeyFilepath, "signer-name", cannedPasswordRetriever))
|
||||
|
@ -143,7 +143,7 @@ func testLoadKeyFromPath(t *testing.T, privKeyID string, privKeyFixture []byte)
|
|||
// check that the appropriate ~/<trust_dir>/private/<key_id>.key file exists
|
||||
expectedImportKeyPath := filepath.Join(keyStorageDir, notary.PrivDir, privKeyID+"."+notary.KeyExtension)
|
||||
_, err = os.Stat(expectedImportKeyPath)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
// verify the key content
|
||||
from, _ := os.OpenFile(expectedImportKeyPath, os.O_RDONLY, notary.PrivExecPerms)
|
||||
|
@ -157,7 +157,7 @@ func testLoadKeyFromPath(t *testing.T, privKeyID string, privKeyFixture []byte)
|
|||
assert.Check(t, is.Equal("ENCRYPTED PRIVATE KEY", keyPEM.Type))
|
||||
|
||||
decryptedKey, err := tufutils.ParsePKCS8ToTufKey(keyPEM.Bytes, []byte(passwd))
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
fixturePEM, _ := pem.Decode(privKeyFixture)
|
||||
assert.Check(t, is.DeepEqual(fixturePEM.Bytes, decryptedKey.Private()))
|
||||
}
|
||||
|
@ -172,13 +172,13 @@ func TestLoadKeyTooPermissive(t *testing.T) {
|
|||
|
||||
func testLoadKeyTooPermissive(t *testing.T, privKeyFixture []byte) {
|
||||
privKeyDir, err := ioutil.TempDir("", "key-load-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(privKeyDir)
|
||||
privKeyFilepath := filepath.Join(privKeyDir, "privkey477.pem")
|
||||
assert.Check(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, 0477))
|
||||
assert.NilError(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, 0477))
|
||||
|
||||
keyStorageDir, err := ioutil.TempDir("", "loaded-keys-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(keyStorageDir)
|
||||
|
||||
// import the key to our keyStorageDir
|
||||
|
@ -187,30 +187,30 @@ func testLoadKeyTooPermissive(t *testing.T, privKeyFixture []byte) {
|
|||
assert.Error(t, err, expected)
|
||||
|
||||
privKeyFilepath = filepath.Join(privKeyDir, "privkey667.pem")
|
||||
assert.Check(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, 0677))
|
||||
assert.NilError(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, 0677))
|
||||
|
||||
_, err = getPrivKeyBytesFromPath(privKeyFilepath)
|
||||
expected = fmt.Sprintf("private key file %s must not be readable or writable by others", privKeyFilepath)
|
||||
assert.Error(t, err, expected)
|
||||
|
||||
privKeyFilepath = filepath.Join(privKeyDir, "privkey777.pem")
|
||||
assert.Check(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, 0777))
|
||||
assert.NilError(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, 0777))
|
||||
|
||||
_, err = getPrivKeyBytesFromPath(privKeyFilepath)
|
||||
expected = fmt.Sprintf("private key file %s must not be readable or writable by others", privKeyFilepath)
|
||||
assert.Error(t, err, expected)
|
||||
|
||||
privKeyFilepath = filepath.Join(privKeyDir, "privkey400.pem")
|
||||
assert.Check(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, 0400))
|
||||
assert.NilError(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, 0400))
|
||||
|
||||
_, err = getPrivKeyBytesFromPath(privKeyFilepath)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
privKeyFilepath = filepath.Join(privKeyDir, "privkey600.pem")
|
||||
assert.Check(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, 0600))
|
||||
assert.NilError(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, 0600))
|
||||
|
||||
_, err = getPrivKeyBytesFromPath(privKeyFilepath)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
var pubKeyFixture = []byte(`-----BEGIN PUBLIC KEY-----
|
||||
|
@ -220,22 +220,22 @@ H3nzy2O6Q/ct4BjOBKa+WCdRtPo78bA+C/7t81ADQO8Jqaj59W50rwoqDQ==
|
|||
|
||||
func TestLoadPubKeyFailure(t *testing.T) {
|
||||
pubKeyDir, err := ioutil.TempDir("", "key-load-test-pubkey-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(pubKeyDir)
|
||||
pubKeyFilepath := filepath.Join(pubKeyDir, "pubkey.pem")
|
||||
assert.Check(t, ioutil.WriteFile(pubKeyFilepath, pubKeyFixture, notary.PrivNoExecPerms))
|
||||
assert.NilError(t, ioutil.WriteFile(pubKeyFilepath, pubKeyFixture, notary.PrivNoExecPerms))
|
||||
keyStorageDir, err := ioutil.TempDir("", "loaded-keys-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(keyStorageDir)
|
||||
|
||||
passwd := "password"
|
||||
cannedPasswordRetriever := passphrase.ConstantRetriever(passwd)
|
||||
keyFileStore, err := storage.NewPrivateKeyFileStorage(keyStorageDir, notary.KeyExtension)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
privKeyImporters := []trustmanager.Importer{keyFileStore}
|
||||
|
||||
pubKeyBytes, err := getPrivKeyBytesFromPath(pubKeyFilepath)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
// import the key to our keyStorageDir - it should fail
|
||||
err = loadPrivKeyBytesToStore(pubKeyBytes, privKeyImporters, pubKeyFilepath, "signer-name", cannedPasswordRetriever)
|
||||
|
|
|
@ -59,7 +59,7 @@ func TestTrustRevokeCommandOfflineErrors(t *testing.T) {
|
|||
cmd := newRevokeCommand(cli)
|
||||
cmd.SetArgs([]string{"reg-name.io/image"})
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Please confirm you would like to delete all signature data for reg-name.io/image? [y/N] \nAborting action."))
|
||||
|
||||
cli = test.NewFakeCli(&fakeClient{})
|
||||
|
@ -82,7 +82,7 @@ func TestTrustRevokeCommandUninitializedErrors(t *testing.T) {
|
|||
cmd := newRevokeCommand(cli)
|
||||
cmd.SetArgs([]string{"reg-name.io/image"})
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Please confirm you would like to delete all signature data for reg-name.io/image? [y/N] \nAborting action."))
|
||||
|
||||
cli = test.NewFakeCli(&fakeClient{})
|
||||
|
@ -106,7 +106,7 @@ func TestTrustRevokeCommandEmptyNotaryRepo(t *testing.T) {
|
|||
cmd := newRevokeCommand(cli)
|
||||
cmd.SetArgs([]string{"reg-name.io/image"})
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Please confirm you would like to delete all signature data for reg-name.io/image? [y/N] \nAborting action."))
|
||||
|
||||
cli = test.NewFakeCli(&fakeClient{})
|
||||
|
@ -129,19 +129,19 @@ func TestNewRevokeTrustAllSigConfirmation(t *testing.T) {
|
|||
cli.SetNotaryClient(getEmptyTargetsNotaryRepository)
|
||||
cmd := newRevokeCommand(cli)
|
||||
cmd.SetArgs([]string{"alpine"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
|
||||
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Please confirm you would like to delete all signature data for alpine? [y/N] \nAborting action."))
|
||||
}
|
||||
|
||||
func TestGetSignableRolesForTargetAndRemoveError(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "notary-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever("password"), trustpinning.TrustPinConfig{})
|
||||
assert.NilError(t, err)
|
||||
target := client.Target{}
|
||||
err = getSignableRolesForTargetAndRemove(target, notaryRepo)
|
||||
assert.Check(t, is.Error(err, "client is offline"))
|
||||
assert.Error(t, err, "client is offline")
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ func TestTrustSignCommandErrors(t *testing.T) {
|
|||
}
|
||||
// change to a tmpdir
|
||||
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
config.SetDir(tmpDir)
|
||||
for _, tc := range testCases {
|
||||
|
@ -83,15 +83,15 @@ func TestTrustSignCommandOfflineErrors(t *testing.T) {
|
|||
|
||||
func TestGetOrGenerateNotaryKey(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "notary-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
// repo is empty, try making a root key
|
||||
rootKeyA, err := getOrGenerateNotaryKey(notaryRepo, data.CanonicalRootRole)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, rootKeyA != nil)
|
||||
|
||||
// we should only have one newly generated key
|
||||
|
@ -101,7 +101,7 @@ func TestGetOrGenerateNotaryKey(t *testing.T) {
|
|||
|
||||
// this time we should get back the same key if we ask for another root key
|
||||
rootKeyB, err := getOrGenerateNotaryKey(notaryRepo, data.CanonicalRootRole)
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, rootKeyB != nil)
|
||||
|
||||
// we should only have one newly generated key
|
||||
|
@ -114,7 +114,7 @@ func TestGetOrGenerateNotaryKey(t *testing.T) {
|
|||
|
||||
// Now also try with a delegation key
|
||||
releasesKey, err := getOrGenerateNotaryKey(notaryRepo, data.RoleName(trust.ReleasesRole))
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, releasesKey != nil)
|
||||
|
||||
// we should now have two keys
|
||||
|
@ -128,20 +128,20 @@ func TestGetOrGenerateNotaryKey(t *testing.T) {
|
|||
|
||||
func TestAddStageSigners(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "notary-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
// stage targets/user
|
||||
userRole := data.RoleName("targets/user")
|
||||
userKey := data.NewPublicKey("algoA", []byte("a"))
|
||||
err = addStagedSigner(notaryRepo, userRole, []data.PublicKey{userKey})
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
// check the changelist for four total changes: two on targets/releases and two on targets/user
|
||||
cl, err := notaryRepo.GetChangelist()
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
changeList := cl.List()
|
||||
assert.Check(t, is.Len(changeList, 4))
|
||||
// ordering is determinstic:
|
||||
|
@ -213,14 +213,14 @@ func TestAddStageSigners(t *testing.T) {
|
|||
|
||||
func TestGetSignedManifestHashAndSize(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "notary-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
target := &client.Target{}
|
||||
target.Hashes, target.Length, err = getSignedManifestHashAndSize(notaryRepo, "test")
|
||||
assert.Check(t, is.Error(err, "client is offline"))
|
||||
assert.Error(t, err, "client is offline")
|
||||
}
|
||||
|
||||
func TestGetReleasedTargetHashAndSize(t *testing.T) {
|
||||
|
@ -231,7 +231,7 @@ func TestGetReleasedTargetHashAndSize(t *testing.T) {
|
|||
oneReleasedTgt = append(oneReleasedTgt, client.TargetSignedStruct{Role: mockDelegationRoleWithName(unreleasedRole), Target: unreleasedTgt})
|
||||
}
|
||||
_, _, err := getReleasedTargetHashAndSize(oneReleasedTgt, "unreleased")
|
||||
assert.Check(t, is.Error(err, "No valid trust data for unreleased"))
|
||||
assert.Error(t, err, "No valid trust data for unreleased")
|
||||
releasedTgt := client.Target{Name: "released", Hashes: data.Hashes{notary.SHA256: []byte("released-hash")}}
|
||||
oneReleasedTgt = append(oneReleasedTgt, client.TargetSignedStruct{Role: mockDelegationRoleWithName("targets/releases"), Target: releasedTgt})
|
||||
hash, _, _ := getReleasedTargetHashAndSize(oneReleasedTgt, "unreleased")
|
||||
|
@ -241,26 +241,26 @@ func TestGetReleasedTargetHashAndSize(t *testing.T) {
|
|||
|
||||
func TestCreateTarget(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "notary-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
_, err = createTarget(notaryRepo, "")
|
||||
assert.Check(t, is.Error(err, "No tag specified"))
|
||||
assert.Error(t, err, "No tag specified")
|
||||
_, err = createTarget(notaryRepo, "1")
|
||||
assert.Check(t, is.Error(err, "client is offline"))
|
||||
assert.Error(t, err, "client is offline")
|
||||
}
|
||||
|
||||
func TestGetExistingSignatureInfoForReleasedTag(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "notary-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
_, err = getExistingSignatureInfoForReleasedTag(notaryRepo, "test")
|
||||
assert.Check(t, is.Error(err, "client is offline"))
|
||||
assert.Error(t, err, "client is offline")
|
||||
}
|
||||
|
||||
func TestPrettyPrintExistingSignatureInfo(t *testing.T) {
|
||||
|
@ -274,7 +274,7 @@ func TestPrettyPrintExistingSignatureInfo(t *testing.T) {
|
|||
|
||||
func TestSignCommandChangeListIsCleanedOnError(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
config.SetDir(tmpDir)
|
||||
|
@ -285,10 +285,10 @@ func TestSignCommandChangeListIsCleanedOnError(t *testing.T) {
|
|||
cmd.SetOutput(ioutil.Discard)
|
||||
|
||||
err = cmd.Execute()
|
||||
assert.Assert(t, is.ErrorContains(err, ""))
|
||||
assert.Assert(t, err != nil)
|
||||
|
||||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "docker.io/library/ubuntu", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
cl, err := notaryRepo.GetChangelist()
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(len(cl.List()), 0))
|
||||
|
|
|
@ -51,7 +51,7 @@ func TestTrustSignerAddErrors(t *testing.T) {
|
|||
},
|
||||
}
|
||||
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
config.SetDir(tmpDir)
|
||||
|
||||
|
@ -67,12 +67,12 @@ func TestTrustSignerAddErrors(t *testing.T) {
|
|||
|
||||
func TestSignerAddCommandNoTargetsKey(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
config.SetDir(tmpDir)
|
||||
|
||||
tmpfile, err := ioutil.TempFile("", "pemfile")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.Remove(tmpfile.Name())
|
||||
|
||||
cli := test.NewFakeCli(&fakeClient{})
|
||||
|
@ -81,12 +81,12 @@ func TestSignerAddCommandNoTargetsKey(t *testing.T) {
|
|||
cmd.SetArgs([]string{"--key", tmpfile.Name(), "alice", "alpine", "linuxkit/alpine"})
|
||||
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, is.Error(cmd.Execute(), fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpfile.Name())))
|
||||
assert.Error(t, cmd.Execute(), fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpfile.Name()))
|
||||
}
|
||||
|
||||
func TestSignerAddCommandBadKeyPath(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
config.SetDir(tmpDir)
|
||||
|
||||
|
@ -96,20 +96,20 @@ func TestSignerAddCommandBadKeyPath(t *testing.T) {
|
|||
cmd.SetArgs([]string{"--key", "/path/to/key.pem", "alice", "alpine"})
|
||||
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, is.Error(cmd.Execute(), "unable to read public key from file: open /path/to/key.pem: no such file or directory"))
|
||||
assert.Error(t, cmd.Execute(), "unable to read public key from file: open /path/to/key.pem: no such file or directory")
|
||||
}
|
||||
|
||||
func TestSignerAddCommandInvalidRepoName(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
config.SetDir(tmpDir)
|
||||
|
||||
pubKeyDir, err := ioutil.TempDir("", "key-load-test-pubkey-")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(pubKeyDir)
|
||||
pubKeyFilepath := filepath.Join(pubKeyDir, "pubkey.pem")
|
||||
assert.Check(t, ioutil.WriteFile(pubKeyFilepath, pubKeyFixture, notary.PrivNoExecPerms))
|
||||
assert.NilError(t, ioutil.WriteFile(pubKeyFilepath, pubKeyFixture, notary.PrivNoExecPerms))
|
||||
|
||||
cli := test.NewFakeCli(&fakeClient{})
|
||||
cli.SetNotaryClient(getUninitializedNotaryRepository)
|
||||
|
@ -118,7 +118,7 @@ func TestSignerAddCommandInvalidRepoName(t *testing.T) {
|
|||
cmd.SetArgs([]string{"--key", pubKeyFilepath, "alice", imageName})
|
||||
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, is.Error(cmd.Execute(), "Failed to add signer to: 870d292919d01a0af7e7f056271dc78792c05f55f49b9b9012b6d89725bd9abd"))
|
||||
assert.Error(t, cmd.Execute(), "Failed to add signer to: 870d292919d01a0af7e7f056271dc78792c05f55f49b9b9012b6d89725bd9abd")
|
||||
expectedErr := fmt.Sprintf("invalid repository name (%s), cannot specify 64-byte hexadecimal strings\n\n", imageName)
|
||||
|
||||
assert.Check(t, is.Equal(expectedErr, cli.ErrBuffer().String()))
|
||||
|
@ -127,11 +127,11 @@ func TestSignerAddCommandInvalidRepoName(t *testing.T) {
|
|||
func TestIngestPublicKeys(t *testing.T) {
|
||||
// Call with a bad path
|
||||
_, err := ingestPublicKeys([]string{"foo", "bar"})
|
||||
assert.Check(t, is.Error(err, "unable to read public key from file: open foo: no such file or directory"))
|
||||
assert.Error(t, err, "unable to read public key from file: open foo: no such file or directory")
|
||||
// Call with real file path
|
||||
tmpfile, err := ioutil.TempFile("", "pemfile")
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.Remove(tmpfile.Name())
|
||||
_, err = ingestPublicKeys([]string{tmpfile.Name()})
|
||||
assert.Check(t, is.Error(err, fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpfile.Name())))
|
||||
assert.Error(t, err, fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpfile.Name()))
|
||||
}
|
||||
|
|
|
@ -71,16 +71,16 @@ func TestRemoveSingleSigner(t *testing.T) {
|
|||
cli := test.NewFakeCli(&fakeClient{})
|
||||
cli.SetNotaryClient(getLoadedNotaryRepository)
|
||||
err := removeSingleSigner(cli, "signed-repo", "test", true)
|
||||
assert.Check(t, is.Error(err, "No signer test for repository signed-repo"))
|
||||
assert.Error(t, err, "No signer test for repository signed-repo")
|
||||
err = removeSingleSigner(cli, "signed-repo", "releases", true)
|
||||
assert.Check(t, is.Error(err, "releases is a reserved keyword and cannot be removed"))
|
||||
assert.Error(t, err, "releases is a reserved keyword and cannot be removed")
|
||||
}
|
||||
|
||||
func TestRemoveMultipleSigners(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{})
|
||||
cli.SetNotaryClient(getLoadedNotaryRepository)
|
||||
err := removeSigner(cli, signerRemoveOptions{signer: "test", repos: []string{"signed-repo", "signed-repo"}, forceYes: true})
|
||||
assert.Check(t, is.Error(err, "Error removing signer from: signed-repo, signed-repo"))
|
||||
assert.Error(t, err, "Error removing signer from: signed-repo, signed-repo")
|
||||
assert.Check(t, is.Contains(cli.ErrBuffer().String(),
|
||||
"No signer test for repository signed-repo"))
|
||||
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Removing signer \"test\" from signed-repo...\n"))
|
||||
|
@ -90,7 +90,7 @@ func TestRemoveLastSignerWarning(t *testing.T) {
|
|||
cli.SetNotaryClient(getLoadedNotaryRepository)
|
||||
|
||||
err := removeSigner(cli, signerRemoveOptions{signer: "alice", repos: []string{"signed-repo"}, forceYes: false})
|
||||
assert.Check(t, err)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Contains(cli.OutBuffer().String(),
|
||||
"The signer \"alice\" signed the last released version of signed-repo. "+
|
||||
"Removing this signer will make signed-repo unpullable. "+
|
||||
|
|
|
@ -93,7 +93,7 @@ func TestTrustViewCommandEmptyNotaryRepoErrors(t *testing.T) {
|
|||
cmd := newViewCommand(cli)
|
||||
cmd.SetArgs([]string{"reg/img:unsigned-tag"})
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Contains(cli.OutBuffer().String(), "No signatures for reg/img:unsigned-tag"))
|
||||
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Administrative keys for reg/img:"))
|
||||
|
||||
|
@ -102,7 +102,7 @@ func TestTrustViewCommandEmptyNotaryRepoErrors(t *testing.T) {
|
|||
cmd = newViewCommand(cli)
|
||||
cmd.SetArgs([]string{"reg/img"})
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Contains(cli.OutBuffer().String(), "No signatures for reg/img"))
|
||||
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Administrative keys for reg/img:"))
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ func TestTrustViewCommandFullRepoWithoutSigners(t *testing.T) {
|
|||
cli.SetNotaryClient(getLoadedWithNoSignersNotaryRepository)
|
||||
cmd := newViewCommand(cli)
|
||||
cmd.SetArgs([]string{"signed-repo"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
|
||||
golden.Assert(t, cli.OutBuffer().String(), "trust-view-full-repo-no-signers.golden")
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ func TestTrustViewCommandOneTagWithoutSigners(t *testing.T) {
|
|||
cli.SetNotaryClient(getLoadedWithNoSignersNotaryRepository)
|
||||
cmd := newViewCommand(cli)
|
||||
cmd.SetArgs([]string{"signed-repo:green"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
|
||||
golden.Assert(t, cli.OutBuffer().String(), "trust-view-one-tag-no-signers.golden")
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ func TestTrustViewCommandFullRepoWithSigners(t *testing.T) {
|
|||
cli.SetNotaryClient(getLoadedNotaryRepository)
|
||||
cmd := newViewCommand(cli)
|
||||
cmd.SetArgs([]string{"signed-repo"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
|
||||
golden.Assert(t, cli.OutBuffer().String(), "trust-view-full-repo-with-signers.golden")
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ func TestTrustViewCommandUnsignedTagInSignedRepo(t *testing.T) {
|
|||
cli.SetNotaryClient(getLoadedNotaryRepository)
|
||||
cmd := newViewCommand(cli)
|
||||
cmd.SetArgs([]string{"signed-repo:unsigned"})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
|
||||
golden.Assert(t, cli.OutBuffer().String(), "trust-view-unsigned-tag-with-signers.golden")
|
||||
}
|
||||
|
|
|
@ -72,14 +72,14 @@ func TestVolumeCreateWithName(t *testing.T) {
|
|||
// Test by flags
|
||||
cmd := newCreateCommand(cli)
|
||||
cmd.Flags().Set("name", name)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal(name, strings.TrimSpace(buf.String())))
|
||||
|
||||
// Then by args
|
||||
buf.Reset()
|
||||
cmd = newCreateCommand(cli)
|
||||
cmd.SetArgs([]string{name})
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal(name, strings.TrimSpace(buf.String())))
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,6 @@ func TestVolumeCreateWithFlags(t *testing.T) {
|
|||
cmd.Flags().Set("opt", "baz=baz")
|
||||
cmd.Flags().Set("label", "lbl1=v1")
|
||||
cmd.Flags().Set("label", "lbl2=v2")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal(name, strings.TrimSpace(cli.OutBuffer().String())))
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ func TestVolumeInspectWithoutFormat(t *testing.T) {
|
|||
})
|
||||
cmd := newInspectCommand(cli)
|
||||
cmd.SetArgs(tc.args)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("volume-inspect-without-format.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ func TestVolumeInspectWithFormat(t *testing.T) {
|
|||
cmd := newInspectCommand(cli)
|
||||
cmd.SetArgs(tc.args)
|
||||
cmd.Flags().Set("format", tc.format)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("volume-inspect-with-format.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ func TestVolumeListWithoutFormat(t *testing.T) {
|
|||
},
|
||||
})
|
||||
cmd := newListCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "volume-list-without-format.golden")
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ func TestVolumeListWithConfigFormat(t *testing.T) {
|
|||
VolumesFormat: "{{ .Name }} {{ .Driver }} {{ .Labels }}",
|
||||
})
|
||||
cmd := newListCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "volume-list-with-config-format.golden")
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,6 @@ func TestVolumeListWithFormat(t *testing.T) {
|
|||
})
|
||||
cmd := newListCommand(cli)
|
||||
cmd.Flags().Set("format", "{{ .Name }} {{ .Driver }} {{ .Labels }}")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "volume-list-with-format.golden")
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ func TestVolumePruneForce(t *testing.T) {
|
|||
})
|
||||
cmd := NewPruneCommand(cli)
|
||||
cmd.Flags().Set("force", "true")
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("volume-prune.%s.golden", tc.name))
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ func TestVolumePrunePromptYes(t *testing.T) {
|
|||
|
||||
cli.SetIn(command.NewInStream(ioutil.NopCloser(strings.NewReader(input))))
|
||||
cmd := NewPruneCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "volume-prune-yes.golden")
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ func TestVolumePrunePromptNo(t *testing.T) {
|
|||
|
||||
cli.SetIn(command.NewInStream(ioutil.NopCloser(strings.NewReader(input))))
|
||||
cmd := NewPruneCommand(cli)
|
||||
assert.Check(t, cmd.Execute())
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), "volume-prune-no.golden")
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue