diff --git a/cli/command/bundlefile/bundlefile_test.go b/cli/command/bundlefile/bundlefile_test.go index 08bf896db6..8837aa1a27 100644 --- a/cli/command/bundlefile/bundlefile_test.go +++ b/cli/command/bundlefile/bundlefile_test.go @@ -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) { diff --git a/cli/command/checkpoint/create_test.go b/cli/command/checkpoint/create_test.go index a74c9922c0..59fdf9d108 100644 --- a/cli/command/checkpoint/create_test.go +++ b/cli/command/checkpoint/create_test.go @@ -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)) diff --git a/cli/command/checkpoint/list_test.go b/cli/command/checkpoint/list_test.go index 5e67084479..2523bba566 100644 --- a/cli/command/checkpoint/list_test.go +++ b/cli/command/checkpoint/list_test.go @@ -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") diff --git a/cli/command/checkpoint/remove_test.go b/cli/command/checkpoint/remove_test.go index f73673608e..9816b2f16c 100644 --- a/cli/command/checkpoint/remove_test.go +++ b/cli/command/checkpoint/remove_test.go @@ -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)) diff --git a/cli/command/cli_test.go b/cli/command/cli_test.go index 6e4f0cdf74..48a87d1bfb 100644 --- a/cli/command/cli_test.go +++ b/cli/command/cli_test.go @@ -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) }) } } diff --git a/cli/command/config/create_test.go b/cli/command/config/create_test.go index a21b59708e..46515ca524 100644 --- a/cli/command/config/create_test.go +++ b/cli/command/config/create_test.go @@ -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()))) } diff --git a/cli/command/config/inspect_test.go b/cli/command/config/inspect_test.go index cd4535db3d..b714e95830 100644 --- a/cli/command/config/inspect_test.go +++ b/cli/command/config/inspect_test.go @@ -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)) } } diff --git a/cli/command/config/ls_test.go b/cli/command/config/ls_test.go index 4eac2df705..3ef7a91783 100644 --- a/cli/command/config/ls_test.go +++ b/cli/command/config/ls_test.go @@ -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") } diff --git a/cli/command/config/remove_test.go b/cli/command/config/remove_test.go index bf8e0dcdc4..6501210dcf 100644 --- a/cli/command/config/remove_test.go +++ b/cli/command/config/remove_test.go @@ -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)) } diff --git a/cli/command/container/attach_test.go b/cli/command/container/attach_test.go index 0d519de65b..9f7831ca06 100644 --- a/cli/command/container/attach_test.go +++ b/cli/command/container/attach_test.go @@ -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()) } } } diff --git a/cli/command/container/cp_test.go b/cli/command/container/cp_test.go index ba45a073a3..78fb3e237f 100644 --- a/cli/command/container/cp_test.go +++ b/cli/command/container/cp_test.go @@ -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) }) } } diff --git a/cli/command/container/create_test.go b/cli/command/container/create_test.go index 32beaa06ab..aa20678eeb 100644 --- a/cli/command/container/create_test.go +++ b/cli/command/container/create_test.go @@ -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) } diff --git a/cli/command/container/list_test.go b/cli/command/container/list_test.go index b4221334c4..9a064eb735 100644 --- a/cli/command/container/list_test.go +++ b/cli/command/container/list_test.go @@ -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") } diff --git a/cli/command/container/opts_test.go b/cli/command/container/opts_test.go index b08f76c536..5d43409662 100644 --- a/cli/command/container/opts_test.go +++ b/cli/command/container/opts_test.go @@ -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 } diff --git a/cli/command/container/ps_test.go b/cli/command/container/ps_test.go index a781c1f590..4ca11dcb41 100644 --- a/cli/command/container/ps_test.go +++ b/cli/command/container/ps_test.go @@ -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)) diff --git a/cli/command/container/run_test.go b/cli/command/container/run_test.go index 71389bd6cf..e05b120410 100644 --- a/cli/command/container/run_test.go +++ b/cli/command/container/run_test.go @@ -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()) } diff --git a/cli/command/formatter/container_test.go b/cli/command/formatter/container_test.go index abe29f21f0..8b1893f8d5 100644 --- a/cli/command/formatter/container_test.go +++ b/cli/command/formatter/container_test.go @@ -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())) } diff --git a/cli/command/formatter/diff_test.go b/cli/command/formatter/diff_test.go index 2caf9447a5..c1f6650beb 100644 --- a/cli/command/formatter/diff_test.go +++ b/cli/command/formatter/diff_test.go @@ -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())) } diff --git a/cli/command/formatter/image_test.go b/cli/command/formatter/image_test.go index a514eb7dde..26488f335a 100644 --- a/cli/command/formatter/image_test.go +++ b/cli/command/formatter/image_test.go @@ -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())) } diff --git a/cli/command/formatter/network_test.go b/cli/command/formatter/network_test.go index 1cc6284615..79b5880543 100644 --- a/cli/command/formatter/network_test.go +++ b/cli/command/formatter/network_test.go @@ -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())) } diff --git a/cli/command/formatter/node_test.go b/cli/command/formatter/node_test.go index c8bb7a34bd..3fa9ceb785 100644 --- a/cli/command/formatter/node_test.go +++ b/cli/command/formatter/node_test.go @@ -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())) } diff --git a/cli/command/formatter/plugin_test.go b/cli/command/formatter/plugin_test.go index aa4062bae0..ebe615dd13 100644 --- a/cli/command/formatter/plugin_test.go +++ b/cli/command/formatter/plugin_test.go @@ -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())) } diff --git a/cli/command/formatter/secret_test.go b/cli/command/formatter/secret_test.go index c58a20b0f4..e62793d3b1 100644 --- a/cli/command/formatter/secret_test.go +++ b/cli/command/formatter/secret_test.go @@ -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())) } diff --git a/cli/command/formatter/service_test.go b/cli/command/formatter/service_test.go index f37459100f..11c00c4b01 100644 --- a/cli/command/formatter/service_test.go +++ b/cli/command/formatter/service_test.go @@ -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())) } diff --git a/cli/command/formatter/stats_test.go b/cli/command/formatter/stats_test.go index a2d023a912..6c88fe8771 100644 --- a/cli/command/formatter/stats_test.go +++ b/cli/command/formatter/stats_test.go @@ -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())) } diff --git a/cli/command/formatter/task_test.go b/cli/command/formatter/task_test.go index b7d42d2546..9dc8a18bb8 100644 --- a/cli/command/formatter/task_test.go +++ b/cli/command/formatter/task_test.go @@ -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())) } diff --git a/cli/command/formatter/trust_test.go b/cli/command/formatter/trust_test.go index bd18c97b5a..4f97996a7c 100644 --- a/cli/command/formatter/trust_test.go +++ b/cli/command/formatter/trust_test.go @@ -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())) } diff --git a/cli/command/formatter/volume_test.go b/cli/command/formatter/volume_test.go index cb876e1d31..425aaed12d 100644 --- a/cli/command/formatter/volume_test.go +++ b/cli/command/formatter/volume_test.go @@ -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())) } diff --git a/cli/command/idresolver/idresolver_test.go b/cli/command/idresolver/idresolver_test.go index b64fca7c25..0ef720a95c 100644 --- a/cli/command/idresolver/idresolver_test.go +++ b/cli/command/idresolver/idresolver_test.go @@ -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)) } } diff --git a/cli/command/image/build_test.go b/cli/command/image/build_test.go index 6012a755c4..a178a93cea 100644 --- a/cli/command/image/build_test.go +++ b/cli/command/image/build_test.go @@ -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) diff --git a/cli/command/image/history_test.go b/cli/command/image/history_test.go index 1005e87486..ce03c8c64d 100644 --- a/cli/command/image/history_test.go +++ b/cli/command/image/history_test.go @@ -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)) } diff --git a/cli/command/image/import_test.go b/cli/command/image/import_test.go index 0bab6ae642..2eefe72479 100644 --- a/cli/command/image/import_test.go +++ b/cli/command/image/import_test.go @@ -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()) } } diff --git a/cli/command/image/inspect_test.go b/cli/command/image/inspect_test.go index 76f47ae003..4bf0547416 100644 --- a/cli/command/image/inspect_test.go +++ b/cli/command/image/inspect_test.go @@ -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)) } diff --git a/cli/command/image/list_test.go b/cli/command/image/list_test.go index 3df7c4b75a..f4ce847262 100644 --- a/cli/command/image/list_test.go +++ b/cli/command/image/list_test.go @@ -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)) } } diff --git a/cli/command/image/load_test.go b/cli/command/image/load_test.go index 69ff76d891..d3ec89e36c 100644 --- a/cli/command/image/load_test.go +++ b/cli/command/image/load_test.go @@ -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)) } } diff --git a/cli/command/image/prune_test.go b/cli/command/image/prune_test.go index 26622db6ff..9c03d83d72 100644 --- a/cli/command/image/prune_test.go +++ b/cli/command/image/prune_test.go @@ -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)) } } diff --git a/cli/command/image/pull_test.go b/cli/command/image/pull_test.go index ba0048fdbb..7770e32952 100644 --- a/cli/command/image/pull_test.go +++ b/cli/command/image/pull_test.go @@ -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)) } } diff --git a/cli/command/image/push_test.go b/cli/command/image/push_test.go index 8031aa4985..72fefc0bde 100644 --- a/cli/command/image/push_test.go +++ b/cli/command/image/push_test.go @@ -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()) } } diff --git a/cli/command/image/remove_test.go b/cli/command/image/remove_test.go index ee5cfd02e0..2c0cc9b0ac 100644 --- a/cli/command/image/remove_test.go +++ b/cli/command/image/remove_test.go @@ -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)) }) diff --git a/cli/command/image/save_test.go b/cli/command/image/save_test.go index f12ba6d805..b87be3c8af 100644 --- a/cli/command/image/save_test.go +++ b/cli/command/image/save_test.go @@ -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() } diff --git a/cli/command/image/tag_test.go b/cli/command/image/tag_test.go index 9db565c8a2..0319cb0522 100644 --- a/cli/command/image/tag_test.go +++ b/cli/command/image/tag_test.go @@ -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) } diff --git a/cli/command/image/trust_test.go b/cli/command/image/trust_test.go index 92b0c49cb1..9aaa60396f 100644 --- a/cli/command/image/trust_test.go +++ b/cli/command/image/trust_test.go @@ -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") } diff --git a/cli/command/manifest/create_test.go b/cli/command/manifest/create_test.go index d3c040e5fb..378aa86041 100644 --- a/cli/command/manifest/create_test.go +++ b/cli/command/manifest/create_test.go @@ -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") } diff --git a/cli/command/manifest/inspect_test.go b/cli/command/manifest/inspect_test.go index 0f879f3c9b..9ba503a80e 100644 --- a/cli/command/manifest/inspect_test.go +++ b/cli/command/manifest/inspect_test.go @@ -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) { diff --git a/cli/command/network/connect_test.go b/cli/command/network/connect_test.go index c4cffc7dd9..d4c9654eaf 100644 --- a/cli/command/network/connect_test.go +++ b/cli/command/network/connect_test.go @@ -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()) } diff --git a/cli/command/network/create_test.go b/cli/command/network/create_test.go index 8880e467be..6a76695c91 100644 --- a/cli/command/network/create_test.go +++ b/cli/command/network/create_test.go @@ -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()))) } diff --git a/cli/command/network/list_test.go b/cli/command/network/list_test.go index 4c1a437c03..558f6cb2ba 100644 --- a/cli/command/network/list_test.go +++ b/cli/command/network/list_test.go @@ -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") } diff --git a/cli/command/node/demote_test.go b/cli/command/node/demote_test.go index d3bfd43474..5bbc7dae36 100644 --- a/cli/command/node/demote_test.go +++ b/cli/command/node/demote_test.go @@ -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()) } diff --git a/cli/command/node/inspect_test.go b/cli/command/node/inspect_test.go index 42a78f8555..73f0a9e872 100644 --- a/cli/command/node/inspect_test.go +++ b/cli/command/node/inspect_test.go @@ -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)) } } diff --git a/cli/command/node/list_test.go b/cli/command/node/list_test.go index 3d57149a08..2d56af8377 100644 --- a/cli/command/node/list_test.go +++ b/cli/command/node/list_test.go @@ -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") } diff --git a/cli/command/node/promote_test.go b/cli/command/node/promote_test.go index 39c5000301..5d5c105dfe 100644 --- a/cli/command/node/promote_test.go +++ b/cli/command/node/promote_test.go @@ -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()) } diff --git a/cli/command/node/ps_test.go b/cli/command/node/ps_test.go index f2a3b59757..2a8533fb08 100644 --- a/cli/command/node/ps_test.go +++ b/cli/command/node/ps_test.go @@ -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)) } } diff --git a/cli/command/node/remove_test.go b/cli/command/node/remove_test.go index 498a827999..17ebb46f75 100644 --- a/cli/command/node/remove_test.go +++ b/cli/command/node/remove_test.go @@ -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()) } diff --git a/cli/command/node/update_test.go b/cli/command/node/update_test.go index c9a2f2108b..6d3f6f0bd4 100644 --- a/cli/command/node/update_test.go +++ b/cli/command/node/update_test.go @@ -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()) } } diff --git a/cli/command/plugin/create_test.go b/cli/command/plugin/create_test.go index a43e5dc6a7..87e17d3793 100644 --- a/cli/command/plugin/create_test.go +++ b/cli/command/plugin/create_test.go @@ -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())) } diff --git a/cli/command/plugin/disable_test.go b/cli/command/plugin/disable_test.go index ab18bef060..592e0e4951 100644 --- a/cli/command/plugin/disable_test.go +++ b/cli/command/plugin/disable_test.go @@ -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())) } diff --git a/cli/command/plugin/enable_test.go b/cli/command/plugin/enable_test.go index 7606ec5bec..42ce53576a 100644 --- a/cli/command/plugin/enable_test.go +++ b/cli/command/plugin/enable_test.go @@ -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())) } diff --git a/cli/command/plugin/remove_test.go b/cli/command/plugin/remove_test.go index 7ce02c6a6c..813c7615f6 100644 --- a/cli/command/plugin/remove_test.go +++ b/cli/command/plugin/remove_test.go @@ -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())) } diff --git a/cli/command/registry_test.go b/cli/command/registry_test.go index 0c56c79737..33407b9f44 100644 --- a/cli/command/registry_test.go +++ b/cli/command/registry_test.go @@ -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)) } } diff --git a/cli/command/secret/create_test.go b/cli/command/secret/create_test.go index 33b077b2d1..7a9492ca0f 100644 --- a/cli/command/secret/create_test.go +++ b/cli/command/secret/create_test.go @@ -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()))) } diff --git a/cli/command/secret/inspect_test.go b/cli/command/secret/inspect_test.go index adee2bcf5f..b23d78beb9 100644 --- a/cli/command/secret/inspect_test.go +++ b/cli/command/secret/inspect_test.go @@ -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)) } } diff --git a/cli/command/secret/ls_test.go b/cli/command/secret/ls_test.go index 4e62fc74f8..371218926c 100644 --- a/cli/command/secret/ls_test.go +++ b/cli/command/secret/ls_test.go @@ -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") } diff --git a/cli/command/secret/remove_test.go b/cli/command/secret/remove_test.go index 80b7b96a80..349f47b387 100644 --- a/cli/command/secret/remove_test.go +++ b/cli/command/secret/remove_test.go @@ -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)) } diff --git a/cli/command/service/generic_resource_opts_test.go b/cli/command/service/generic_resource_opts_test.go index 3d64a99857..ffc7f4ca64 100644 --- a/cli/command/service/generic_resource_opts_test.go +++ b/cli/command/service/generic_resource_opts_test.go @@ -18,6 +18,6 @@ func TestValidateSingleGenericResource(t *testing.T) { for _, v := range correct { _, err := ValidateSingleGenericResource(v) - assert.Check(t, err) + assert.NilError(t, err) } } diff --git a/cli/command/service/list_test.go b/cli/command/service/list_test.go index 18e8f09fca..6286906f32 100644 --- a/cli/command/service/list_test.go +++ b/cli/command/service/list_test.go @@ -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") } diff --git a/cli/command/service/opts_test.go b/cli/command/service/opts_test.go index 8127d61d68..a84072382b 100644 --- a/cli/command/service/opts_test.go +++ b/cli/command/service/opts_test.go @@ -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))) } diff --git a/cli/command/service/ps_test.go b/cli/command/service/ps_test.go index 0f50edc0d0..bb66849f55 100644 --- a/cli/command/service/ps_test.go +++ b/cli/command/service/ps_test.go @@ -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) { diff --git a/cli/command/service/rollback_test.go b/cli/command/service/rollback_test.go index e76eb68a47..6e5620cbe7 100644 --- a/cli/command/service/rollback_test.go +++ b/cli/command/service/rollback_test.go @@ -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)) } } diff --git a/cli/command/service/update_test.go b/cli/command/service/update_test.go index a4cc53385c..d647093254 100644 --- a/cli/command/service/update_test.go +++ b/cli/command/service/update_test.go @@ -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)) } diff --git a/cli/command/stack/list_test.go b/cli/command/stack/list_test.go index 569093bf16..b3a9bdc3b7 100644 --- a/cli/command/stack/list_test.go +++ b/cli/command/stack/list_test.go @@ -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) } } diff --git a/cli/command/stack/ps_test.go b/cli/command/stack/ps_test.go index 798ad17c15..b3cce8d58a 100644 --- a/cli/command/stack/ps_test.go +++ b/cli/command/stack/ps_test.go @@ -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") } diff --git a/cli/command/stack/remove_test.go b/cli/command/stack/remove_test.go index 7770d47145..5f27a9b32a 100644 --- a/cli/command/stack/remove_test.go +++ b/cli/command/stack/remove_test.go @@ -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)) diff --git a/cli/command/stack/services_test.go b/cli/command/stack/services_test.go index a4738549ec..195d65c346 100644 --- a/cli/command/stack/services_test.go +++ b/cli/command/stack/services_test.go @@ -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") } diff --git a/cli/command/stack/swarm/deploy_bundlefile_test.go b/cli/command/stack/swarm/deploy_bundlefile_test.go index cc1535fc9b..4e66caabed 100644 --- a/cli/command/stack/swarm/deploy_bundlefile_test.go +++ b/cli/command/stack/swarm/deploy_bundlefile_test.go @@ -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)) } diff --git a/cli/command/stack/swarm/deploy_composefile_test.go b/cli/command/stack/swarm/deploy_composefile_test.go index a864c5b658..91c318cd63 100644 --- a/cli/command/stack/swarm/deploy_composefile_test.go +++ b/cli/command/stack/swarm/deploy_composefile_test.go @@ -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) } diff --git a/cli/command/stack/swarm/deploy_test.go b/cli/command/stack/swarm/deploy_test.go index 15199c3731..3fdbbdbee7 100644 --- a/cli/command/stack/swarm/deploy_test.go +++ b/cli/command/stack/swarm/deploy_test.go @@ -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)) diff --git a/cli/command/swarm/ca_test.go b/cli/command/swarm/ca_test.go index 72b20e61e4..d11739ec37 100644 --- a/cli/command/swarm/ca_test.go +++ b/cli/command/swarm/ca_test.go @@ -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----- diff --git a/cli/command/swarm/init_test.go b/cli/command/swarm/init_test.go index f7852ed948..22712726ca 100644 --- a/cli/command/swarm/init_test.go +++ b/cli/command/swarm/init_test.go @@ -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)) } } diff --git a/cli/command/swarm/join_test.go b/cli/command/swarm/join_test.go index 3e14db18b5..7817df1440 100644 --- a/cli/command/swarm/join_test.go +++ b/cli/command/swarm/join_test.go @@ -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)) } } diff --git a/cli/command/swarm/join_token_test.go b/cli/command/swarm/join_token_test.go index d69469c64c..ca042671b2 100644 --- a/cli/command/swarm/join_token_test.go +++ b/cli/command/swarm/join_token_test.go @@ -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)) } } diff --git a/cli/command/swarm/leave_test.go b/cli/command/swarm/leave_test.go index 8a2db2ce31..07eac2c4da 100644 --- a/cli/command/swarm/leave_test.go +++ b/cli/command/swarm/leave_test.go @@ -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()))) } diff --git a/cli/command/swarm/opts_test.go b/cli/command/swarm/opts_test.go index 5f31f4cb90..6aa12b89c4 100644 --- a/cli/command/swarm/opts_test.go +++ b/cli/command/swarm/opts_test.go @@ -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())) } diff --git a/cli/command/swarm/unlock_key_test.go b/cli/command/swarm/unlock_key_test.go index cb5e2a9217..aaade6fe9c 100644 --- a/cli/command/swarm/unlock_key_test.go +++ b/cli/command/swarm/unlock_key_test.go @@ -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)) } } diff --git a/cli/command/swarm/unlock_test.go b/cli/command/swarm/unlock_test.go index b60766ce1c..eb481d13ca 100644 --- a/cli/command/swarm/unlock_test.go +++ b/cli/command/swarm/unlock_test.go @@ -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()) } diff --git a/cli/command/swarm/update_test.go b/cli/command/swarm/update_test.go index 8186c5ebaa..60e44ddfe0 100644 --- a/cli/command/swarm/update_test.go +++ b/cli/command/swarm/update_test.go @@ -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)) } } diff --git a/cli/command/system/prune_test.go b/cli/command/system/prune_test.go index a3133eebb6..b763c480ab 100644 --- a/cli/command/system/prune_test.go +++ b/cli/command/system/prune_test.go @@ -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 diff --git a/cli/command/task/print_test.go b/cli/command/task/print_test.go index 7803b799ef..731d2de16f 100644 --- a/cli/command/task/print_test.go +++ b/cli/command/task/print_test.go @@ -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") } diff --git a/cli/command/trust/helpers_test.go b/cli/command/trust/helpers_test.go index 8cd189c256..216ae5ce9d 100644 --- a/cli/command/trust/helpers_test.go +++ b/cli/command/trust/helpers_test.go @@ -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") } diff --git a/cli/command/trust/inspect_test.go b/cli/command/trust/inspect_test.go index 7224f1dad9..5bf41f5487 100644 --- a/cli/command/trust/inspect_test.go +++ b/cli/command/trust/inspect_test.go @@ -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") } diff --git a/cli/command/trust/key_generate_test.go b/cli/command/trust/key_generate_test.go index eadf43ea21..bad5164941 100644 --- a/cli/command/trust/key_generate_test.go +++ b/cli/command/trust/key_generate_test.go @@ -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 ~//private/.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)) diff --git a/cli/command/trust/key_load_test.go b/cli/command/trust/key_load_test.go index 12b7f84d48..b24f528ef0 100644 --- a/cli/command/trust/key_load_test.go +++ b/cli/command/trust/key_load_test.go @@ -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 ~//private/.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) diff --git a/cli/command/trust/revoke_test.go b/cli/command/trust/revoke_test.go index 25d579e452..adc20f5074 100644 --- a/cli/command/trust/revoke_test.go +++ b/cli/command/trust/revoke_test.go @@ -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") } diff --git a/cli/command/trust/sign_test.go b/cli/command/trust/sign_test.go index 4cc338f10d..523b2792e4 100644 --- a/cli/command/trust/sign_test.go +++ b/cli/command/trust/sign_test.go @@ -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)) diff --git a/cli/command/trust/signer_add_test.go b/cli/command/trust/signer_add_test.go index e691b10f5c..d2e1e21481 100644 --- a/cli/command/trust/signer_add_test.go +++ b/cli/command/trust/signer_add_test.go @@ -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())) } diff --git a/cli/command/trust/signer_remove_test.go b/cli/command/trust/signer_remove_test.go index 4f625c1dbb..660d7264b5 100644 --- a/cli/command/trust/signer_remove_test.go +++ b/cli/command/trust/signer_remove_test.go @@ -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. "+ diff --git a/cli/command/trust/view_test.go b/cli/command/trust/view_test.go index 7758c94ad1..535ce4fd55 100644 --- a/cli/command/trust/view_test.go +++ b/cli/command/trust/view_test.go @@ -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") } diff --git a/cli/command/volume/create_test.go b/cli/command/volume/create_test.go index 0e70d92e0e..d68d065e27 100644 --- a/cli/command/volume/create_test.go +++ b/cli/command/volume/create_test.go @@ -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()))) } diff --git a/cli/command/volume/inspect_test.go b/cli/command/volume/inspect_test.go index 56dbf76be9..c827b7281c 100644 --- a/cli/command/volume/inspect_test.go +++ b/cli/command/volume/inspect_test.go @@ -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)) } } diff --git a/cli/command/volume/list_test.go b/cli/command/volume/list_test.go index b004e349f5..52b3e46603 100644 --- a/cli/command/volume/list_test.go +++ b/cli/command/volume/list_test.go @@ -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") } diff --git a/cli/command/volume/prune_test.go b/cli/command/volume/prune_test.go index 79a7d4fc07..0d75d3b75d 100644 --- a/cli/command/volume/prune_test.go +++ b/cli/command/volume/prune_test.go @@ -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") } } diff --git a/cli/command/volume/remove_test.go b/cli/command/volume/remove_test.go index 5abf026dd7..f773a3648e 100644 --- a/cli/command/volume/remove_test.go +++ b/cli/command/volume/remove_test.go @@ -40,5 +40,5 @@ func TestVolumeRemoveErrors(t *testing.T) { func TestNodeRemoveMultiple(t *testing.T) { cmd := newRemoveCommand(test.NewFakeCli(&fakeClient{})) cmd.SetArgs([]string{"volume1", "volume2"}) - assert.Check(t, cmd.Execute()) + assert.NilError(t, cmd.Execute()) } diff --git a/cli/compose/convert/compose_test.go b/cli/compose/convert/compose_test.go index 2963b96c01..a2ff2f1723 100644 --- a/cli/compose/convert/compose_test.go +++ b/cli/compose/convert/compose_test.go @@ -121,7 +121,7 @@ func TestSecrets(t *testing.T) { } specs, err := Secrets(namespace, source) - assert.Check(t, err) + assert.NilError(t, err) assert.Assert(t, is.Len(specs, 1)) secret := specs[0] assert.Check(t, is.Equal("foo_one", secret.Name)) @@ -152,7 +152,7 @@ func TestConfigs(t *testing.T) { } specs, err := Configs(namespace, source) - assert.Check(t, err) + assert.NilError(t, err) assert.Assert(t, is.Len(specs, 1)) config := specs[0] assert.Check(t, is.Equal("foo_one", config.Name)) diff --git a/cli/compose/convert/service_test.go b/cli/compose/convert/service_test.go index e3c72b68db..044b4e3e30 100644 --- a/cli/compose/convert/service_test.go +++ b/cli/compose/convert/service_test.go @@ -20,13 +20,13 @@ import ( func TestConvertRestartPolicyFromNone(t *testing.T) { policy, err := convertRestartPolicy("no", nil) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual((*swarm.RestartPolicy)(nil), policy)) } func TestConvertRestartPolicyFromUnknown(t *testing.T) { _, err := convertRestartPolicy("unknown", nil) - assert.Check(t, is.Error(err, "unknown restart policy: unknown")) + assert.Error(t, err, "unknown restart policy: unknown") } func TestConvertRestartPolicyFromAlways(t *testing.T) { @@ -34,7 +34,7 @@ func TestConvertRestartPolicyFromAlways(t *testing.T) { expected := &swarm.RestartPolicy{ Condition: swarm.RestartPolicyConditionAny, } - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, policy)) } @@ -45,7 +45,7 @@ func TestConvertRestartPolicyFromFailure(t *testing.T) { Condition: swarm.RestartPolicyConditionOnFailure, MaxAttempts: &attempts, } - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, policy)) } @@ -84,7 +84,7 @@ func TestConvertResourcesFull(t *testing.T) { }, } resources, err := convertResources(source) - assert.Check(t, err) + assert.NilError(t, err) expected := &swarm.ResourceRequirements{ Limits: &swarm.Resources{ @@ -109,7 +109,7 @@ func TestConvertResourcesOnlyMemory(t *testing.T) { }, } resources, err := convertResources(source) - assert.Check(t, err) + assert.NilError(t, err) expected := &swarm.ResourceRequirements{ Limits: &swarm.Resources{ @@ -140,7 +140,7 @@ func TestConvertHealthcheck(t *testing.T) { } healthcheck, err := convertHealthcheck(source) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, healthcheck)) } @@ -151,7 +151,7 @@ func TestConvertHealthcheckDisable(t *testing.T) { } healthcheck, err := convertHealthcheck(source) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, healthcheck)) } @@ -161,7 +161,7 @@ func TestConvertHealthcheckDisableWithTest(t *testing.T) { Test: []string{"EXEC", "touch"}, } _, err := convertHealthcheck(source) - assert.Check(t, is.Error(err, "test and disable can't be set at the same time")) + assert.Error(t, err, "test and disable can't be set at the same time") } func TestConvertEndpointSpec(t *testing.T) { @@ -195,7 +195,7 @@ func TestConvertEndpointSpec(t *testing.T) { }, } - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, *endpoint)) } @@ -212,7 +212,7 @@ func TestConvertServiceNetworksOnlyDefault(t *testing.T) { }, } - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, configs)) } @@ -250,7 +250,7 @@ func TestConvertServiceNetworks(t *testing.T) { sortedConfigs := byTargetSort(configs) sort.Sort(&sortedConfigs) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, []swarm.NetworkAttachmentConfig(sortedConfigs))) } @@ -273,7 +273,7 @@ func TestConvertServiceNetworksCustomDefault(t *testing.T) { }, } - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, []swarm.NetworkAttachmentConfig(configs))) } @@ -294,7 +294,7 @@ func (s byTargetSort) Swap(i, j int) { func TestConvertDNSConfigEmpty(t *testing.T) { dnsConfig, err := convertDNSConfig(nil, nil) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual((*swarm.DNSConfig)(nil), dnsConfig)) } @@ -305,7 +305,7 @@ var ( func TestConvertDNSConfigAll(t *testing.T) { dnsConfig, err := convertDNSConfig(nameservers, search) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(&swarm.DNSConfig{ Nameservers: nameservers, Search: search, @@ -314,7 +314,7 @@ func TestConvertDNSConfigAll(t *testing.T) { func TestConvertDNSConfigNameservers(t *testing.T) { dnsConfig, err := convertDNSConfig(nameservers, nil) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(&swarm.DNSConfig{ Nameservers: nameservers, Search: nil, @@ -323,7 +323,7 @@ func TestConvertDNSConfigNameservers(t *testing.T) { func TestConvertDNSConfigSearch(t *testing.T) { dnsConfig, err := convertDNSConfig(nil, search) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(&swarm.DNSConfig{ Nameservers: nil, Search: search, @@ -332,20 +332,20 @@ func TestConvertDNSConfigSearch(t *testing.T) { func TestConvertCredentialSpec(t *testing.T) { swarmSpec, err := convertCredentialSpec(composetypes.CredentialSpecConfig{}) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Nil(swarmSpec)) swarmSpec, err = convertCredentialSpec(composetypes.CredentialSpecConfig{ File: "/foo", }) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Equal(swarmSpec.File, "/foo")) assert.Check(t, is.Equal(swarmSpec.Registry, "")) swarmSpec, err = convertCredentialSpec(composetypes.CredentialSpecConfig{ Registry: "foo", }) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Equal(swarmSpec.File, "")) assert.Check(t, is.Equal(swarmSpec.Registry, "foo")) diff --git a/cli/compose/convert/volume_test.go b/cli/compose/convert/volume_test.go index 0cb3e72342..d7d45eedf5 100644 --- a/cli/compose/convert/volume_test.go +++ b/cli/compose/convert/volume_test.go @@ -19,7 +19,7 @@ func TestConvertVolumeToMountAnonymousVolume(t *testing.T) { Target: "/foo/bar", } mount, err := convertVolumeToMount(config, volumes{}, NewNamespace("foo")) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, mount)) } @@ -32,7 +32,7 @@ func TestConvertVolumeToMountAnonymousBind(t *testing.T) { }, } _, err := convertVolumeToMount(config, volumes{}, NewNamespace("foo")) - assert.Check(t, is.Error(err, "invalid bind source, source cannot be empty")) + assert.Error(t, err, "invalid bind source, source cannot be empty") } func TestConvertVolumeToMountUnapprovedType(t *testing.T) { @@ -41,7 +41,7 @@ func TestConvertVolumeToMountUnapprovedType(t *testing.T) { Target: "/foo/bar", } _, err := convertVolumeToMount(config, volumes{}, NewNamespace("foo")) - assert.Check(t, is.Error(err, "volume type must be volume, bind, or tmpfs")) + assert.Error(t, err, "volume type must be volume, bind, or tmpfs") } func TestConvertVolumeToMountConflictingOptionsBindInVolume(t *testing.T) { @@ -56,7 +56,7 @@ func TestConvertVolumeToMountConflictingOptionsBindInVolume(t *testing.T) { }, } _, err := convertVolumeToMount(config, volumes{}, namespace) - assert.Check(t, is.Error(err, "bind options are incompatible with type volume")) + assert.Error(t, err, "bind options are incompatible with type volume") } func TestConvertVolumeToMountConflictingOptionsTmpfsInVolume(t *testing.T) { @@ -71,7 +71,7 @@ func TestConvertVolumeToMountConflictingOptionsTmpfsInVolume(t *testing.T) { }, } _, err := convertVolumeToMount(config, volumes{}, namespace) - assert.Check(t, is.Error(err, "tmpfs options are incompatible with type volume")) + assert.Error(t, err, "tmpfs options are incompatible with type volume") } func TestConvertVolumeToMountConflictingOptionsVolumeInBind(t *testing.T) { @@ -86,7 +86,7 @@ func TestConvertVolumeToMountConflictingOptionsVolumeInBind(t *testing.T) { }, } _, err := convertVolumeToMount(config, volumes{}, namespace) - assert.Check(t, is.Error(err, "volume options are incompatible with type bind")) + assert.Error(t, err, "volume options are incompatible with type bind") } func TestConvertVolumeToMountConflictingOptionsTmpfsInBind(t *testing.T) { @@ -101,7 +101,7 @@ func TestConvertVolumeToMountConflictingOptionsTmpfsInBind(t *testing.T) { }, } _, err := convertVolumeToMount(config, volumes{}, namespace) - assert.Check(t, is.Error(err, "tmpfs options are incompatible with type bind")) + assert.Error(t, err, "tmpfs options are incompatible with type bind") } func TestConvertVolumeToMountConflictingOptionsBindInTmpfs(t *testing.T) { @@ -115,7 +115,7 @@ func TestConvertVolumeToMountConflictingOptionsBindInTmpfs(t *testing.T) { }, } _, err := convertVolumeToMount(config, volumes{}, namespace) - assert.Check(t, is.Error(err, "bind options are incompatible with type tmpfs")) + assert.Error(t, err, "bind options are incompatible with type tmpfs") } func TestConvertVolumeToMountConflictingOptionsVolumeInTmpfs(t *testing.T) { @@ -129,7 +129,7 @@ func TestConvertVolumeToMountConflictingOptionsVolumeInTmpfs(t *testing.T) { }, } _, err := convertVolumeToMount(config, volumes{}, namespace) - assert.Check(t, is.Error(err, "volume options are incompatible with type tmpfs")) + assert.Error(t, err, "volume options are incompatible with type tmpfs") } func TestConvertVolumeToMountNamedVolume(t *testing.T) { @@ -174,7 +174,7 @@ func TestConvertVolumeToMountNamedVolume(t *testing.T) { }, } mount, err := convertVolumeToMount(config, stackVolumes, namespace) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, mount)) } @@ -221,7 +221,7 @@ func TestConvertVolumeToMountNamedVolumeWithNameCustomizd(t *testing.T) { }, } mount, err := convertVolumeToMount(config, stackVolumes, namespace) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, mount)) } @@ -245,7 +245,7 @@ func TestConvertVolumeToMountNamedVolumeExternal(t *testing.T) { Target: "/foo", } mount, err := convertVolumeToMount(config, stackVolumes, namespace) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, mount)) } @@ -274,7 +274,7 @@ func TestConvertVolumeToMountNamedVolumeExternalNoCopy(t *testing.T) { }, } mount, err := convertVolumeToMount(config, stackVolumes, namespace) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, mount)) } @@ -296,7 +296,7 @@ func TestConvertVolumeToMountBind(t *testing.T) { Bind: &composetypes.ServiceVolumeBind{Propagation: "shared"}, } mount, err := convertVolumeToMount(config, stackVolumes, namespace) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, mount)) } @@ -309,7 +309,7 @@ func TestConvertVolumeToMountVolumeDoesNotExist(t *testing.T) { ReadOnly: true, } _, err := convertVolumeToMount(config, volumes{}, namespace) - assert.Check(t, is.Error(err, "undefined volume \"unknown\"")) + assert.Error(t, err, "undefined volume \"unknown\"") } func TestConvertTmpfsToMountVolume(t *testing.T) { @@ -326,7 +326,7 @@ func TestConvertTmpfsToMountVolume(t *testing.T) { TmpfsOptions: &mount.TmpfsOptions{SizeBytes: 1000}, } mount, err := convertVolumeToMount(config, volumes{}, NewNamespace("foo")) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, mount)) } @@ -341,5 +341,5 @@ func TestConvertTmpfsToMountVolumeWithSource(t *testing.T) { } _, err := convertVolumeToMount(config, volumes{}, NewNamespace("foo")) - assert.Check(t, is.Error(err, "invalid tmpfs source, source must be empty")) + assert.Error(t, err, "invalid tmpfs source, source must be empty") } diff --git a/cli/compose/interpolation/interpolation_test.go b/cli/compose/interpolation/interpolation_test.go index 63e078c1d5..42ea55ff1f 100644 --- a/cli/compose/interpolation/interpolation_test.go +++ b/cli/compose/interpolation/interpolation_test.go @@ -47,7 +47,7 @@ func TestInterpolate(t *testing.T) { }, } result, err := Interpolate(services, Options{LookupValue: defaultMapping}) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, result)) } @@ -58,7 +58,7 @@ func TestInvalidInterpolation(t *testing.T) { }, } _, err := Interpolate(services, Options{LookupValue: defaultMapping}) - assert.Check(t, is.Error(err, `invalid interpolation format for servicea.image: "${". You may need to escape any $ with another $.`)) + assert.Error(t, err, `invalid interpolation format for servicea.image: "${". You may need to escape any $ with another $.`) } func TestInterpolateWithDefaults(t *testing.T) { @@ -75,7 +75,7 @@ func TestInterpolateWithDefaults(t *testing.T) { }, } result, err := Interpolate(config, Options{}) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, result)) } @@ -92,7 +92,7 @@ func TestInterpolateWithCast(t *testing.T) { LookupValue: defaultMapping, TypeCastMapping: map[Path]Cast{NewPath(PathMatchAll, "replicas"): toInt}, }) - assert.Check(t, err) + assert.NilError(t, err) expected := map[string]interface{}{ "foo": map[string]interface{}{ "replicas": 5, diff --git a/cli/compose/loader/loader_test.go b/cli/compose/loader/loader_test.go index 93f87cefa8..4219593725 100644 --- a/cli/compose/loader/loader_test.go +++ b/cli/compose/loader/loader_test.go @@ -410,7 +410,7 @@ services: - QUX= - QUUX `, map[string]string{"QUX": "qux"}) - assert.Check(t, err) + assert.NilError(t, err) expected := types.MappingWithEquals{ "FOO": strPtr("1"), diff --git a/cli/compose/loader/types_test.go b/cli/compose/loader/types_test.go index 7ada6a1ab0..b324c8e580 100644 --- a/cli/compose/loader/types_test.go +++ b/cli/compose/loader/types_test.go @@ -319,12 +319,12 @@ configs: {} ` actual, err := yaml.Marshal(cfg) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Equal(expected, string(actual))) // Make sure the expected still dict, err := ParseYAML([]byte("version: '3.6'\n" + expected)) - assert.Check(t, err) + assert.NilError(t, err) _, err = Load(buildConfigDetails(dict, map[string]string{})) - assert.Check(t, err) + assert.NilError(t, err) } diff --git a/cli/compose/loader/volume_test.go b/cli/compose/loader/volume_test.go index 8eb4c6d991..5e96b0aeff 100644 --- a/cli/compose/loader/volume_test.go +++ b/cli/compose/loader/volume_test.go @@ -13,7 +13,7 @@ func TestParseVolumeAnonymousVolume(t *testing.T) { for _, path := range []string{"/path", "/path/foo"} { volume, err := ParseVolume(path) expected := types.ServiceVolumeConfig{Type: "volume", Target: path} - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, volume)) } } @@ -22,21 +22,21 @@ func TestParseVolumeAnonymousVolumeWindows(t *testing.T) { for _, path := range []string{"C:\\path", "Z:\\path\\foo"} { volume, err := ParseVolume(path) expected := types.ServiceVolumeConfig{Type: "volume", Target: path} - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, volume)) } } func TestParseVolumeTooManyColons(t *testing.T) { _, err := ParseVolume("/foo:/foo:ro:foo") - assert.Check(t, is.Error(err, "invalid spec: /foo:/foo:ro:foo: too many colons")) + assert.Error(t, err, "invalid spec: /foo:/foo:ro:foo: too many colons") } func TestParseVolumeShortVolumes(t *testing.T) { for _, path := range []string{".", "/a"} { volume, err := ParseVolume(path) expected := types.ServiceVolumeConfig{Type: "volume", Target: path} - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, volume)) } } @@ -56,7 +56,7 @@ func TestParseVolumeBindMount(t *testing.T) { Source: path, Target: "/target", } - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, volume)) } } @@ -74,7 +74,7 @@ func TestParseVolumeRelativeBindMountWindows(t *testing.T) { Source: path, Target: "d:\\target", } - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, volume)) } } @@ -87,7 +87,7 @@ func TestParseVolumeWithBindOptions(t *testing.T) { Target: "/target", Bind: &types.ServiceVolumeBind{Propagation: "slave"}, } - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, volume)) } @@ -100,13 +100,13 @@ func TestParseVolumeWithBindOptionsWindows(t *testing.T) { ReadOnly: true, Bind: &types.ServiceVolumeBind{Propagation: "rprivate"}, } - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, volume)) } func TestParseVolumeWithInvalidVolumeOptions(t *testing.T) { _, err := ParseVolume("name:/target:bogus") - assert.Check(t, err) + assert.NilError(t, err) } func TestParseVolumeWithVolumeOptions(t *testing.T) { @@ -117,7 +117,7 @@ func TestParseVolumeWithVolumeOptions(t *testing.T) { Target: "/target", Volume: &types.ServiceVolumeVolume{NoCopy: true}, } - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, volume)) } @@ -130,7 +130,7 @@ func TestParseVolumeWithReadOnly(t *testing.T) { Target: "/target", ReadOnly: true, } - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, volume)) } } @@ -144,7 +144,7 @@ func TestParseVolumeWithRW(t *testing.T) { Target: "/target", ReadOnly: false, } - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.DeepEqual(expected, volume)) } } diff --git a/cli/compose/schema/schema_test.go b/cli/compose/schema/schema_test.go index 7dd9d296a9..f80af40113 100644 --- a/cli/compose/schema/schema_test.go +++ b/cli/compose/schema/schema_test.go @@ -18,7 +18,7 @@ func TestValidate(t *testing.T) { }, } - assert.Check(t, Validate(config, "3.0")) + assert.NilError(t, Validate(config, "3.0")) } func TestValidateUndefinedTopLevelOption(t *testing.T) { @@ -42,7 +42,7 @@ func TestValidateAllowsXTopLevelFields(t *testing.T) { } err := Validate(config, "3.4") - assert.Check(t, err) + assert.NilError(t, err) } func TestValidateSecretConfigNames(t *testing.T) { @@ -61,7 +61,7 @@ func TestValidateSecretConfigNames(t *testing.T) { } err := Validate(config, "3.5") - assert.Check(t, err) + assert.NilError(t, err) } func TestValidateInvalidVersion(t *testing.T) { @@ -99,7 +99,7 @@ func TestValidatePlacement(t *testing.T) { }, } - assert.Check(t, Validate(config, "3.3")) + assert.NilError(t, Validate(config, "3.3")) } func TestValidateIsolation(t *testing.T) { @@ -112,5 +112,5 @@ func TestValidateIsolation(t *testing.T) { }, }, } - assert.Check(t, Validate(config, "3.5")) + assert.NilError(t, Validate(config, "3.5")) } diff --git a/cli/compose/template/template_test.go b/cli/compose/template/template_test.go index 7adef7b13a..5e4ff9b3ed 100644 --- a/cli/compose/template/template_test.go +++ b/cli/compose/template/template_test.go @@ -20,7 +20,7 @@ func defaultMapping(name string) (string, bool) { func TestEscaped(t *testing.T) { result, err := Substitute("$${foo}", defaultMapping) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Equal("${foo}", result)) } @@ -50,7 +50,7 @@ func TestInvalid(t *testing.T) { func TestNoValueNoDefault(t *testing.T) { for _, template := range []string{"This ${missing} var", "This ${BAR} var"} { result, err := Substitute(template, defaultMapping) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Equal("This var", result)) } } @@ -58,7 +58,7 @@ func TestNoValueNoDefault(t *testing.T) { func TestValueNoDefault(t *testing.T) { for _, template := range []string{"This $FOO var", "This ${FOO} var"} { result, err := Substitute(template, defaultMapping) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Equal("This first var", result)) } } @@ -66,26 +66,26 @@ func TestValueNoDefault(t *testing.T) { func TestNoValueWithDefault(t *testing.T) { for _, template := range []string{"ok ${missing:-def}", "ok ${missing-def}"} { result, err := Substitute(template, defaultMapping) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Equal("ok def", result)) } } func TestEmptyValueWithSoftDefault(t *testing.T) { result, err := Substitute("ok ${BAR:-def}", defaultMapping) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Equal("ok def", result)) } func TestEmptyValueWithHardDefault(t *testing.T) { result, err := Substitute("ok ${BAR-def}", defaultMapping) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Equal("ok ", result)) } func TestNonAlphanumericDefault(t *testing.T) { result, err := Substitute("ok ${BAR:-/non:-alphanumeric}", defaultMapping) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Equal("ok /non:-alphanumeric", result)) } @@ -144,7 +144,7 @@ func TestDefaultsForMandatoryVariables(t *testing.T) { for _, tc := range testCases { result, err := Substitute(tc.template, defaultMapping) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Equal(tc.expected, result)) } } diff --git a/cli/config/credentials/native_store_test.go b/cli/config/credentials/native_store_test.go index c73ddd1ea3..57a506f62c 100644 --- a/cli/config/credentials/native_store_test.go +++ b/cli/config/credentials/native_store_test.go @@ -227,7 +227,7 @@ func TestNativeStoreGetMissingCredentials(t *testing.T) { fileStore: NewFileStore(f), } _, err := s.Get(missingCredsAddress) - assert.Check(t, err) + assert.NilError(t, err) } func TestNativeStoreGetInvalidAddress(t *testing.T) { diff --git a/cli/flags/common_test.go b/cli/flags/common_test.go index 1482c33f6c..2f06e11e44 100644 --- a/cli/flags/common_test.go +++ b/cli/flags/common_test.go @@ -20,7 +20,7 @@ func TestCommonOptionsInstallFlags(t *testing.T) { "--tlscert=\"/foo/cert\"", "--tlskey=\"/foo/key\"", }) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Equal("/foo/cafile", opts.TLSOptions.CAFile)) assert.Check(t, is.Equal("/foo/cert", opts.TLSOptions.CertFile)) assert.Check(t, is.Equal(opts.TLSOptions.KeyFile, "/foo/key")) @@ -36,7 +36,7 @@ func TestCommonOptionsInstallFlagsWithDefaults(t *testing.T) { opts.InstallFlags(flags) err := flags.Parse([]string{}) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Equal(defaultPath("ca.pem"), opts.TLSOptions.CAFile)) assert.Check(t, is.Equal(defaultPath("cert.pem"), opts.TLSOptions.CertFile)) assert.Check(t, is.Equal(defaultPath("key.pem"), opts.TLSOptions.KeyFile)) diff --git a/cli/manifest/store/store_test.go b/cli/manifest/store/store_test.go index bd3ba419a7..669b81e7c5 100644 --- a/cli/manifest/store/store_test.go +++ b/cli/manifest/store/store_test.go @@ -96,7 +96,7 @@ func TestStoreSaveAndGet(t *testing.T) { t.Run(testcase.manifestRef.String(), func(t *testing.T) { actual, err := store.Get(testcase.listRef, testcase.manifestRef) if testcase.expectedErr != "" { - assert.Check(t, is.Error(err, testcase.expectedErr)) + assert.Error(t, err, testcase.expectedErr) assert.Check(t, IsNotFound(err)) return } @@ -131,6 +131,6 @@ func TestStoreGetListDoesNotExist(t *testing.T) { listRef := ref("list") _, err := store.GetList(listRef) - assert.Check(t, is.Error(err, "No such manifest: list")) + assert.Error(t, err, "No such manifest: list") assert.Check(t, IsNotFound(err)) } diff --git a/cli/trust/trust_test.go b/cli/trust/trust_test.go index 0cb1f1dd26..67e181ba20 100644 --- a/cli/trust/trust_test.go +++ b/cli/trust/trust_test.go @@ -16,46 +16,46 @@ import ( func TestGetTag(t *testing.T) { ref, err := reference.ParseNormalizedNamed("ubuntu@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2") - assert.Check(t, err) + assert.NilError(t, err) tag := getTag(ref) assert.Check(t, is.Equal("", tag)) ref, err = reference.ParseNormalizedNamed("alpine:latest") - assert.Check(t, err) + assert.NilError(t, err) tag = getTag(ref) assert.Check(t, is.Equal(tag, "latest")) ref, err = reference.ParseNormalizedNamed("alpine") - assert.Check(t, err) + assert.NilError(t, err) tag = getTag(ref) assert.Check(t, is.Equal(tag, "")) } func TestGetDigest(t *testing.T) { ref, err := reference.ParseNormalizedNamed("ubuntu@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2") - assert.Check(t, err) + assert.NilError(t, err) d := getDigest(ref) assert.Check(t, is.Equal(digest.Digest("sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2"), d)) ref, err = reference.ParseNormalizedNamed("alpine:latest") - assert.Check(t, err) + assert.NilError(t, err) d = getDigest(ref) assert.Check(t, is.Equal(digest.Digest(""), d)) ref, err = reference.ParseNormalizedNamed("alpine") - assert.Check(t, err) + assert.NilError(t, err) d = getDigest(ref) assert.Check(t, is.Equal(digest.Digest(""), d)) } func TestGetSignableRolesError(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 = GetSignableRoles(notaryRepo, &target) - assert.Check(t, is.Error(err, "client is offline")) + assert.Error(t, err, "client is offline") } diff --git a/cmd/docker/docker_test.go b/cmd/docker/docker_test.go index 4165388b80..22a157a8be 100644 --- a/cmd/docker/docker_test.go +++ b/cmd/docker/docker_test.go @@ -19,7 +19,7 @@ func TestClientDebugEnabled(t *testing.T) { cmd.Flags().Set("debug", "true") err := cmd.PersistentPreRunE(cmd, []string{}) - assert.Check(t, err) + assert.NilError(t, err) assert.Check(t, is.Equal("1", os.Getenv("DEBUG"))) assert.Check(t, is.Equal(logrus.DebugLevel, logrus.GetLevel())) } @@ -29,5 +29,5 @@ func TestExitStatusForInvalidSubcommandWithHelpFlag(t *testing.T) { cmd := newDockerCommand(command.NewDockerCli(os.Stdin, discard, discard)) cmd.SetArgs([]string{"help", "invalid"}) err := cmd.Execute() - assert.Check(t, is.Error(err, "unknown help topic: invalid")) + assert.Error(t, err, "unknown help topic: invalid") } diff --git a/opts/duration_test.go b/opts/duration_test.go index 66db3aaefb..937585d89e 100644 --- a/opts/duration_test.go +++ b/opts/duration_test.go @@ -16,15 +16,15 @@ func TestDurationOptString(t *testing.T) { func TestDurationOptSetAndValue(t *testing.T) { var duration DurationOpt - assert.Check(t, duration.Set("300s")) + assert.NilError(t, duration.Set("300s")) assert.Check(t, is.Equal(time.Duration(300*10e8), *duration.Value())) - assert.Check(t, duration.Set("-300s")) + assert.NilError(t, duration.Set("-300s")) assert.Check(t, is.Equal(time.Duration(-300*10e8), *duration.Value())) } func TestPositiveDurationOptSetAndValue(t *testing.T) { var duration PositiveDurationOpt - assert.Check(t, duration.Set("300s")) + assert.NilError(t, duration.Set("300s")) assert.Check(t, is.Equal(time.Duration(300*10e8), *duration.Value())) - assert.Check(t, is.Error(duration.Set("-300s"), "duration cannot be negative")) + assert.Error(t, duration.Set("-300s"), "duration cannot be negative") } diff --git a/opts/mount_test.go b/opts/mount_test.go index 2262e33713..bf7b0f2012 100644 --- a/opts/mount_test.go +++ b/opts/mount_test.go @@ -38,7 +38,7 @@ func TestMountOptSetBindNoErrorBind(t *testing.T) { } { var mount MountOpt - assert.Check(t, mount.Set(testcase)) + assert.NilError(t, mount.Set(testcase)) mounts := mount.Value() assert.Assert(t, is.Len(mounts, 1)) @@ -60,7 +60,7 @@ func TestMountOptSetVolumeNoError(t *testing.T) { } { var mount MountOpt - assert.Check(t, mount.Set(testcase)) + assert.NilError(t, mount.Set(testcase)) mounts := mount.Value() assert.Assert(t, is.Len(mounts, 1)) @@ -76,74 +76,74 @@ func TestMountOptSetVolumeNoError(t *testing.T) { // volume mount. func TestMountOptDefaultType(t *testing.T) { var mount MountOpt - assert.Check(t, mount.Set("target=/target,source=/foo")) + assert.NilError(t, mount.Set("target=/target,source=/foo")) assert.Check(t, is.Equal(mounttypes.TypeVolume, mount.values[0].Type)) } func TestMountOptSetErrorNoTarget(t *testing.T) { var mount MountOpt - assert.Check(t, is.Error(mount.Set("type=volume,source=/foo"), "target is required")) + assert.Error(t, mount.Set("type=volume,source=/foo"), "target is required") } func TestMountOptSetErrorInvalidKey(t *testing.T) { var mount MountOpt - assert.Check(t, is.Error(mount.Set("type=volume,bogus=foo"), "unexpected key 'bogus' in 'bogus=foo'")) + assert.Error(t, mount.Set("type=volume,bogus=foo"), "unexpected key 'bogus' in 'bogus=foo'") } func TestMountOptSetErrorInvalidField(t *testing.T) { var mount MountOpt - assert.Check(t, is.Error(mount.Set("type=volume,bogus"), "invalid field 'bogus' must be a key=value pair")) + assert.Error(t, mount.Set("type=volume,bogus"), "invalid field 'bogus' must be a key=value pair") } func TestMountOptSetErrorInvalidReadOnly(t *testing.T) { var mount MountOpt - assert.Check(t, is.Error(mount.Set("type=volume,readonly=no"), "invalid value for readonly: no")) - assert.Check(t, is.Error(mount.Set("type=volume,readonly=invalid"), "invalid value for readonly: invalid")) + assert.Error(t, mount.Set("type=volume,readonly=no"), "invalid value for readonly: no") + assert.Error(t, mount.Set("type=volume,readonly=invalid"), "invalid value for readonly: invalid") } func TestMountOptDefaultEnableReadOnly(t *testing.T) { var m MountOpt - assert.Check(t, m.Set("type=bind,target=/foo,source=/foo")) + assert.NilError(t, m.Set("type=bind,target=/foo,source=/foo")) assert.Check(t, !m.values[0].ReadOnly) m = MountOpt{} - assert.Check(t, m.Set("type=bind,target=/foo,source=/foo,readonly")) + assert.NilError(t, m.Set("type=bind,target=/foo,source=/foo,readonly")) assert.Check(t, m.values[0].ReadOnly) m = MountOpt{} - assert.Check(t, m.Set("type=bind,target=/foo,source=/foo,readonly=1")) + assert.NilError(t, m.Set("type=bind,target=/foo,source=/foo,readonly=1")) assert.Check(t, m.values[0].ReadOnly) m = MountOpt{} - assert.Check(t, m.Set("type=bind,target=/foo,source=/foo,readonly=true")) + assert.NilError(t, m.Set("type=bind,target=/foo,source=/foo,readonly=true")) assert.Check(t, m.values[0].ReadOnly) m = MountOpt{} - assert.Check(t, m.Set("type=bind,target=/foo,source=/foo,readonly=0")) + assert.NilError(t, m.Set("type=bind,target=/foo,source=/foo,readonly=0")) assert.Check(t, !m.values[0].ReadOnly) } func TestMountOptVolumeNoCopy(t *testing.T) { var m MountOpt - assert.Check(t, m.Set("type=volume,target=/foo,volume-nocopy")) + assert.NilError(t, m.Set("type=volume,target=/foo,volume-nocopy")) assert.Check(t, is.Equal("", m.values[0].Source)) m = MountOpt{} - assert.Check(t, m.Set("type=volume,target=/foo,source=foo")) + assert.NilError(t, m.Set("type=volume,target=/foo,source=foo")) assert.Check(t, m.values[0].VolumeOptions == nil) m = MountOpt{} - assert.Check(t, m.Set("type=volume,target=/foo,source=foo,volume-nocopy=true")) + assert.NilError(t, m.Set("type=volume,target=/foo,source=foo,volume-nocopy=true")) assert.Check(t, m.values[0].VolumeOptions != nil) assert.Check(t, m.values[0].VolumeOptions.NoCopy) m = MountOpt{} - assert.Check(t, m.Set("type=volume,target=/foo,source=foo,volume-nocopy")) + assert.NilError(t, m.Set("type=volume,target=/foo,source=foo,volume-nocopy")) assert.Check(t, m.values[0].VolumeOptions != nil) assert.Check(t, m.values[0].VolumeOptions.NoCopy) m = MountOpt{} - assert.Check(t, m.Set("type=volume,target=/foo,source=foo,volume-nocopy=1")) + assert.NilError(t, m.Set("type=volume,target=/foo,source=foo,volume-nocopy=1")) assert.Check(t, m.values[0].VolumeOptions != nil) assert.Check(t, m.values[0].VolumeOptions.NoCopy) } @@ -162,7 +162,7 @@ func TestMountOptSetTmpfsNoError(t *testing.T) { } { var mount MountOpt - assert.Check(t, mount.Set(testcase)) + assert.NilError(t, mount.Set(testcase)) mounts := mount.Value() assert.Assert(t, is.Len(mounts, 1)) diff --git a/opts/network_test.go b/opts/network_test.go index 639bf05e87..357ac10804 100644 --- a/opts/network_test.go +++ b/opts/network_test.go @@ -23,7 +23,7 @@ func TestNetworkOptLegacySyntax(t *testing.T) { } for _, tc := range testCases { var network NetworkOpt - assert.Check(t, network.Set(tc.value)) + assert.NilError(t, network.Set(tc.value)) assert.Check(t, is.DeepEqual(tc.expected, network.Value())) } } @@ -70,7 +70,7 @@ func TestNetworkOptCompleteSyntax(t *testing.T) { } for _, tc := range testCases { var network NetworkOpt - assert.Check(t, network.Set(tc.value)) + assert.NilError(t, network.Set(tc.value)) assert.Check(t, is.DeepEqual(tc.expected, network.Value())) } } diff --git a/opts/port_test.go b/opts/port_test.go index fc7506fdaa..7f07a86cfe 100644 --- a/opts/port_test.go +++ b/opts/port_test.go @@ -99,7 +99,7 @@ func TestPortOptValidSimpleSyntax(t *testing.T) { } for _, tc := range testCases { var port PortOpt - assert.Check(t, port.Set(tc.value)) + assert.NilError(t, port.Set(tc.value)) assert.Check(t, is.Len(port.Value(), len(tc.expected))) for _, expectedPortConfig := range tc.expected { assertContains(t, port.Value(), expectedPortConfig) @@ -190,7 +190,7 @@ func TestPortOptValidComplexSyntax(t *testing.T) { } for _, tc := range testCases { var port PortOpt - assert.Check(t, port.Set(tc.value)) + assert.NilError(t, port.Set(tc.value)) assert.Check(t, is.Len(port.Value(), len(tc.expected))) for _, expectedPortConfig := range tc.expected { assertContains(t, port.Value(), expectedPortConfig) @@ -278,7 +278,7 @@ func TestPortOptInvalidSimpleSyntax(t *testing.T) { } for _, tc := range testCases { var port PortOpt - assert.Check(t, is.Error(port.Set(tc.value), tc.expectedError)) + assert.Error(t, port.Set(tc.value), tc.expectedError) } } diff --git a/opts/quotedstring_test.go b/opts/quotedstring_test.go index ffef407db0..a23448f1b1 100644 --- a/opts/quotedstring_test.go +++ b/opts/quotedstring_test.go @@ -10,7 +10,7 @@ import ( func TestQuotedStringSetWithQuotes(t *testing.T) { value := "" qs := NewQuotedString(&value) - assert.Check(t, qs.Set(`"something"`)) + assert.NilError(t, qs.Set(`"something"`)) assert.Check(t, is.Equal("something", qs.String())) assert.Check(t, is.Equal("something", value)) } @@ -18,13 +18,13 @@ func TestQuotedStringSetWithQuotes(t *testing.T) { func TestQuotedStringSetWithMismatchedQuotes(t *testing.T) { value := "" qs := NewQuotedString(&value) - assert.Check(t, qs.Set(`"something'`)) + assert.NilError(t, qs.Set(`"something'`)) assert.Check(t, is.Equal(`"something'`, qs.String())) } func TestQuotedStringSetWithNoQuotes(t *testing.T) { value := "" qs := NewQuotedString(&value) - assert.Check(t, qs.Set("something")) + assert.NilError(t, qs.Set("something")) assert.Check(t, is.Equal("something", qs.String())) } diff --git a/opts/secret_test.go b/opts/secret_test.go index 3482ccc32a..95ed752148 100644 --- a/opts/secret_test.go +++ b/opts/secret_test.go @@ -12,7 +12,7 @@ func TestSecretOptionsSimple(t *testing.T) { var opt SecretOpt testCase := "app-secret" - assert.Check(t, opt.Set(testCase)) + assert.NilError(t, opt.Set(testCase)) reqs := opt.Value() assert.Assert(t, is.Len(reqs, 1)) @@ -27,7 +27,7 @@ func TestSecretOptionsSourceTarget(t *testing.T) { var opt SecretOpt testCase := "source=foo,target=testing" - assert.Check(t, opt.Set(testCase)) + assert.NilError(t, opt.Set(testCase)) reqs := opt.Value() assert.Assert(t, is.Len(reqs, 1)) @@ -40,7 +40,7 @@ func TestSecretOptionsShorthand(t *testing.T) { var opt SecretOpt testCase := "src=foo,target=testing" - assert.Check(t, opt.Set(testCase)) + assert.NilError(t, opt.Set(testCase)) reqs := opt.Value() assert.Assert(t, is.Len(reqs, 1)) @@ -52,7 +52,7 @@ func TestSecretOptionsCustomUidGid(t *testing.T) { var opt SecretOpt testCase := "source=foo,target=testing,uid=1000,gid=1001" - assert.Check(t, opt.Set(testCase)) + assert.NilError(t, opt.Set(testCase)) reqs := opt.Value() assert.Assert(t, is.Len(reqs, 1)) @@ -67,7 +67,7 @@ func TestSecretOptionsCustomMode(t *testing.T) { var opt SecretOpt testCase := "source=foo,target=testing,uid=1000,gid=1001,mode=0444" - assert.Check(t, opt.Set(testCase)) + assert.NilError(t, opt.Set(testCase)) reqs := opt.Value() assert.Assert(t, is.Len(reqs, 1)) diff --git a/service/logs/parse_logs_test.go b/service/logs/parse_logs_test.go index e0aee51bd7..a8f612ce4a 100644 --- a/service/logs/parse_logs_test.go +++ b/service/logs/parse_logs_test.go @@ -25,7 +25,7 @@ func TestParseLogDetails(t *testing.T) { t.Run(testcase.line, func(t *testing.T) { actual, err := ParseLogDetails(testcase.line) if testcase.err != nil { - assert.Check(t, is.Error(err, testcase.err.Error())) + assert.Error(t, err, testcase.err.Error()) return } assert.Check(t, is.DeepEqual(testcase.expected, actual)) diff --git a/templates/templates_test.go b/templates/templates_test.go index 66fafa2f07..fa4d773395 100644 --- a/templates/templates_test.go +++ b/templates/templates_test.go @@ -11,30 +11,30 @@ import ( // GitHub #32120 func TestParseJSONFunctions(t *testing.T) { tm, err := Parse(`{{json .Ports}}`) - assert.Check(t, err) + assert.NilError(t, err) var b bytes.Buffer - assert.Check(t, tm.Execute(&b, map[string]string{"Ports": "0.0.0.0:2->8/udp"})) + assert.NilError(t, tm.Execute(&b, map[string]string{"Ports": "0.0.0.0:2->8/udp"})) want := "\"0.0.0.0:2->8/udp\"" assert.Check(t, is.Equal(want, b.String())) } func TestParseStringFunctions(t *testing.T) { tm, err := Parse(`{{join (split . ":") "/"}}`) - assert.Check(t, err) + assert.NilError(t, err) var b bytes.Buffer - assert.Check(t, tm.Execute(&b, "text:with:colon")) + assert.NilError(t, tm.Execute(&b, "text:with:colon")) want := "text/with/colon" assert.Check(t, is.Equal(want, b.String())) } func TestNewParse(t *testing.T) { tm, err := NewParse("foo", "this is a {{ . }}") - assert.Check(t, err) + assert.NilError(t, err) var b bytes.Buffer - assert.Check(t, tm.Execute(&b, "string")) + assert.NilError(t, tm.Execute(&b, "string")) want := "this is a string" assert.Check(t, is.Equal(want, b.String())) } @@ -66,17 +66,17 @@ func TestParseTruncateFunction(t *testing.T) { for _, testCase := range testCases { tm, err := Parse(testCase.template) - assert.Check(t, err) + assert.NilError(t, err) t.Run("Non Empty Source Test with template: "+testCase.template, func(t *testing.T) { var b bytes.Buffer - assert.Check(t, tm.Execute(&b, source)) + assert.NilError(t, tm.Execute(&b, source)) assert.Check(t, is.Equal(testCase.expected, b.String())) }) t.Run("Empty Source Test with template: "+testCase.template, func(t *testing.T) { var c bytes.Buffer - assert.Check(t, tm.Execute(&c, "")) + assert.NilError(t, tm.Execute(&c, "")) assert.Check(t, is.Equal("", c.String())) })