mirror of https://github.com/docker/cli.git
Replace deprecated Cobra command.SetOutput() with command.SetOut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
4f058143c7
commit
719169db63
|
@ -128,7 +128,7 @@ func newPluginCommand(dockerCli *command.DockerCli, plugin *cobra.Command, meta
|
||||||
}
|
}
|
||||||
opts, flags := cli.SetupPluginRootCommand(cmd)
|
opts, flags := cli.SetupPluginRootCommand(cmd)
|
||||||
|
|
||||||
cmd.SetOutput(dockerCli.Out())
|
cmd.SetOut(dockerCli.Out())
|
||||||
|
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
plugin,
|
plugin,
|
||||||
|
|
|
@ -41,7 +41,7 @@ func TestCheckpointCreateErrors(t *testing.T) {
|
||||||
})
|
})
|
||||||
cmd := newCreateCommand(cli)
|
cmd := newCreateCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ func TestCheckpointListErrors(t *testing.T) {
|
||||||
})
|
})
|
||||||
cmd := newListCommand(cli)
|
cmd := newListCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ func TestCheckpointRemoveErrors(t *testing.T) {
|
||||||
})
|
})
|
||||||
cmd := newRemoveCommand(cli)
|
cmd := newRemoveCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ func (cli *DockerCli) In() *streams.In {
|
||||||
// ShowHelp shows the command help.
|
// ShowHelp shows the command help.
|
||||||
func ShowHelp(err io.Writer) func(*cobra.Command, []string) error {
|
func ShowHelp(err io.Writer) func(*cobra.Command, []string) error {
|
||||||
return func(cmd *cobra.Command, args []string) error {
|
return func(cmd *cobra.Command, args []string) error {
|
||||||
cmd.SetOutput(err)
|
cmd.SetOut(err)
|
||||||
cmd.HelpFunc()(cmd, args)
|
cmd.HelpFunc()(cmd, args)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ func TestConfigCreateErrors(t *testing.T) {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ func TestConfigInspectErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ func TestConfigListErrors(t *testing.T) {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ func TestConfigRemoveErrors(t *testing.T) {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ func TestConfigRemoveContinueAfterError(t *testing.T) {
|
||||||
|
|
||||||
cmd := newConfigRemoveCommand(cli)
|
cmd := newConfigRemoveCommand(cli)
|
||||||
cmd.SetArgs(names)
|
cmd.SetArgs(names)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.Error(t, cmd.Execute(), "error removing config: foo")
|
assert.Error(t, cmd.Execute(), "error removing config: foo")
|
||||||
assert.Check(t, is.DeepEqual(names, removedConfigs))
|
assert.Check(t, is.DeepEqual(names, removedConfigs))
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ func TestNewAttachCommandErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cmd := NewAttachCommand(test.NewFakeCli(&fakeClient{inspectFunc: tc.containerInspectFunc}))
|
cmd := NewAttachCommand(test.NewFakeCli(&fakeClient{inspectFunc: tc.containerInspectFunc}))
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ func TestNewCreateCommandWithContentTrustErrors(t *testing.T) {
|
||||||
}, test.EnableContentTrust)
|
}, test.EnableContentTrust)
|
||||||
cli.SetNotaryClient(tc.notaryFunc)
|
cli.SetNotaryClient(tc.notaryFunc)
|
||||||
cmd := NewCreateCommand(cli)
|
cmd := NewCreateCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.ErrorContains(t, err, tc.expectedError)
|
assert.ErrorContains(t, err, tc.expectedError)
|
||||||
|
@ -250,7 +250,7 @@ func TestNewCreateCommandWithWarnings(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewCreateCommand(cli)
|
cmd := NewCreateCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
@ -298,7 +298,7 @@ func TestCreateContainerWithProxyConfig(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewCreateCommand(cli)
|
cmd := NewCreateCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs([]string{"image:tag"})
|
cmd.SetArgs([]string{"image:tag"})
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
|
@ -220,7 +220,7 @@ func TestNewExecCommandErrors(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cli := test.NewFakeCli(&fakeClient{inspectFunc: tc.containerInspectFunc})
|
cli := test.NewFakeCli(&fakeClient{inspectFunc: tc.containerInspectFunc})
|
||||||
cmd := NewExecCommand(cli)
|
cmd := NewExecCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ func TestContainerExportOutputToFile(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewExportCommand(cli)
|
cmd := NewExportCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs([]string{"-o", dir.Join("foo"), "container"})
|
cmd.SetArgs([]string{"-o", dir.Join("foo"), "container"})
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ func TestContainerExportOutputToIrregularFile(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewExportCommand(cli)
|
cmd := NewExportCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs([]string{"-o", "/dev/random", "container"})
|
cmd.SetArgs([]string{"-o", "/dev/random", "container"})
|
||||||
|
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
|
|
|
@ -161,7 +161,7 @@ func TestContainerListErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ func TestRunCommandWithContentTrustErrors(t *testing.T) {
|
||||||
cli.SetNotaryClient(tc.notaryFunc)
|
cli.SetNotaryClient(tc.notaryFunc)
|
||||||
cmd := NewRunCommand(cli)
|
cmd := NewRunCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.Assert(t, err != nil)
|
assert.Assert(t, err != nil)
|
||||||
assert.Assert(t, is.Contains(cli.ErrBuffer().String(), tc.expectedError))
|
assert.Assert(t, is.Contains(cli.ErrBuffer().String(), tc.expectedError))
|
||||||
|
|
|
@ -130,7 +130,7 @@ func TestRunBuildFromGitHubSpecialCase(t *testing.T) {
|
||||||
cmd := NewBuildCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := NewBuildCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
// Clone a small repo that exists so git doesn't prompt for credentials
|
// Clone a small repo that exists so git doesn't prompt for credentials
|
||||||
cmd.SetArgs([]string{"github.com/docker/for-win"})
|
cmd.SetArgs([]string{"github.com/docker/for-win"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.ErrorContains(t, err, "unable to prepare context")
|
assert.ErrorContains(t, err, "unable to prepare context")
|
||||||
assert.ErrorContains(t, err, "docker-build-git")
|
assert.ErrorContains(t, err, "docker-build-git")
|
||||||
|
@ -154,7 +154,7 @@ func TestRunBuildFromLocalGitHubDir(t *testing.T) {
|
||||||
client := test.NewFakeCli(&fakeClient{})
|
client := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := NewBuildCommand(client)
|
cmd := NewBuildCommand(client)
|
||||||
cmd.SetArgs([]string{buildDir})
|
cmd.SetArgs([]string{buildDir})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
err = cmd.Execute()
|
err = cmd.Execute()
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func TestNewHistoryCommandErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cmd := NewHistoryCommand(test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc}))
|
cmd := NewHistoryCommand(test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc}))
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cli := test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc})
|
cli := test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc})
|
||||||
cmd := NewHistoryCommand(cli)
|
cmd := NewHistoryCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
|
@ -36,7 +36,7 @@ func TestNewImportCommandErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cmd := NewImportCommand(test.NewFakeCli(&fakeClient{imageImportFunc: tc.imageImportFunc}))
|
cmd := NewImportCommand(test.NewFakeCli(&fakeClient{imageImportFunc: tc.imageImportFunc}))
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ func TestNewImportCommandErrors(t *testing.T) {
|
||||||
|
|
||||||
func TestNewImportCommandInvalidFile(t *testing.T) {
|
func TestNewImportCommandInvalidFile(t *testing.T) {
|
||||||
cmd := NewImportCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := NewImportCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs([]string{"testdata/import-command-success.unexistent-file"})
|
cmd.SetArgs([]string{"testdata/import-command-success.unexistent-file"})
|
||||||
assert.ErrorContains(t, cmd.Execute(), "testdata/import-command-success.unexistent-file")
|
assert.ErrorContains(t, cmd.Execute(), "testdata/import-command-success.unexistent-file")
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ func TestNewImportCommandSuccess(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cmd := NewImportCommand(test.NewFakeCli(&fakeClient{imageImportFunc: tc.imageImportFunc}))
|
cmd := NewImportCommand(test.NewFakeCli(&fakeClient{imageImportFunc: tc.imageImportFunc}))
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ func TestNewInspectCommandErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cmd := newInspectCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := newInspectCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ func TestNewInspectCommandSuccess(t *testing.T) {
|
||||||
imageInspectInvocationCount = 0
|
imageInspectInvocationCount = 0
|
||||||
cli := test.NewFakeCli(&fakeClient{imageInspectFunc: tc.imageInspectFunc})
|
cli := test.NewFakeCli(&fakeClient{imageInspectFunc: tc.imageInspectFunc})
|
||||||
cmd := newInspectCommand(cli)
|
cmd := newInspectCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
|
@ -36,7 +36,7 @@ func TestNewImagesCommandErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cmd := NewImagesCommand(test.NewFakeCli(&fakeClient{imageListFunc: tc.imageListFunc}))
|
cmd := NewImagesCommand(test.NewFakeCli(&fakeClient{imageListFunc: tc.imageListFunc}))
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ func TestNewImagesCommandSuccess(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{imageListFunc: tc.imageListFunc})
|
cli := test.NewFakeCli(&fakeClient{imageListFunc: tc.imageListFunc})
|
||||||
cli.SetConfigFile(&configfile.ConfigFile{ImagesFormat: tc.imageFormat})
|
cli.SetConfigFile(&configfile.ConfigFile{ImagesFormat: tc.imageFormat})
|
||||||
cmd := NewImagesCommand(cli)
|
cmd := NewImagesCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
|
@ -44,7 +44,7 @@ func TestNewLoadCommandErrors(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{imageLoadFunc: tc.imageLoadFunc})
|
cli := test.NewFakeCli(&fakeClient{imageLoadFunc: tc.imageLoadFunc})
|
||||||
cli.In().SetIsTerminal(tc.isTerminalIn)
|
cli.In().SetIsTerminal(tc.isTerminalIn)
|
||||||
cmd := NewLoadCommand(cli)
|
cmd := NewLoadCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ func TestNewLoadCommandErrors(t *testing.T) {
|
||||||
func TestNewLoadCommandInvalidInput(t *testing.T) {
|
func TestNewLoadCommandInvalidInput(t *testing.T) {
|
||||||
expectedError := "open *"
|
expectedError := "open *"
|
||||||
cmd := NewLoadCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := NewLoadCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs([]string{"--input", "*"})
|
cmd.SetArgs([]string{"--input", "*"})
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.ErrorContains(t, err, expectedError)
|
assert.ErrorContains(t, err, expectedError)
|
||||||
|
@ -92,7 +92,7 @@ func TestNewLoadCommandSuccess(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cli := test.NewFakeCli(&fakeClient{imageLoadFunc: tc.imageLoadFunc})
|
cli := test.NewFakeCli(&fakeClient{imageLoadFunc: tc.imageLoadFunc})
|
||||||
cmd := NewLoadCommand(cli)
|
cmd := NewLoadCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
|
@ -39,7 +39,7 @@ func TestNewPruneCommandErrors(t *testing.T) {
|
||||||
cmd := NewPruneCommand(test.NewFakeCli(&fakeClient{
|
cmd := NewPruneCommand(test.NewFakeCli(&fakeClient{
|
||||||
imagesPruneFunc: tc.imagesPruneFunc,
|
imagesPruneFunc: tc.imagesPruneFunc,
|
||||||
}))
|
}))
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ func TestNewPruneCommandSuccess(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cli := test.NewFakeCli(&fakeClient{imagesPruneFunc: tc.imagesPruneFunc})
|
cli := test.NewFakeCli(&fakeClient{imagesPruneFunc: tc.imagesPruneFunc})
|
||||||
cmd := NewPruneCommand(cli)
|
cmd := NewPruneCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
|
@ -40,7 +40,7 @@ func TestNewPullCommandErrors(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := NewPullCommand(cli)
|
cmd := NewPullCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ func TestNewPullCommandSuccess(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewPullCommand(cli)
|
cmd := NewPullCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
@ -118,7 +118,7 @@ func TestNewPullCommandWithContentTrustErrors(t *testing.T) {
|
||||||
}, test.EnableContentTrust)
|
}, test.EnableContentTrust)
|
||||||
cli.SetNotaryClient(tc.notaryFunc)
|
cli.SetNotaryClient(tc.notaryFunc)
|
||||||
cmd := NewPullCommand(cli)
|
cmd := NewPullCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.ErrorContains(t, err, tc.expectedError)
|
assert.ErrorContains(t, err, tc.expectedError)
|
||||||
|
|
|
@ -41,7 +41,7 @@ func TestNewPushCommandErrors(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cli := test.NewFakeCli(&fakeClient{imagePushFunc: tc.imagePushFunc})
|
cli := test.NewFakeCli(&fakeClient{imagePushFunc: tc.imagePushFunc})
|
||||||
cmd := NewPushCommand(cli)
|
cmd := NewPushCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ func TestNewPushCommandSuccess(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewPushCommand(cli)
|
cmd := NewPushCommand(cli)
|
||||||
cmd.SetOutput(cli.OutBuffer())
|
cmd.SetOut(cli.OutBuffer())
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
if tc.output != "" {
|
if tc.output != "" {
|
||||||
|
|
|
@ -68,7 +68,7 @@ func TestNewRemoveCommandErrors(t *testing.T) {
|
||||||
cmd := NewRemoveCommand(test.NewFakeCli(&fakeClient{
|
cmd := NewRemoveCommand(test.NewFakeCli(&fakeClient{
|
||||||
imageRemoveFunc: tc.imageRemoveFunc,
|
imageRemoveFunc: tc.imageRemoveFunc,
|
||||||
}))
|
}))
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
})
|
})
|
||||||
|
@ -124,7 +124,7 @@ func TestNewRemoveCommandSuccess(t *testing.T) {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{imageRemoveFunc: tc.imageRemoveFunc})
|
cli := test.NewFakeCli(&fakeClient{imageRemoveFunc: tc.imageRemoveFunc})
|
||||||
cmd := NewRemoveCommand(cli)
|
cmd := NewRemoveCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
assert.Check(t, is.Equal(tc.expectedStderr, cli.ErrBuffer().String()))
|
assert.Check(t, is.Equal(tc.expectedStderr, cli.ErrBuffer().String()))
|
||||||
|
|
|
@ -56,7 +56,7 @@ func TestNewSaveCommandErrors(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{imageSaveFunc: tc.imageSaveFunc})
|
cli := test.NewFakeCli(&fakeClient{imageSaveFunc: tc.imageSaveFunc})
|
||||||
cli.Out().SetIsTerminal(tc.isTerminal)
|
cli.Out().SetIsTerminal(tc.isTerminal)
|
||||||
cmd := NewSaveCommand(cli)
|
cmd := NewSaveCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ func TestNewSaveCommandSuccess(t *testing.T) {
|
||||||
return ioutil.NopCloser(strings.NewReader("")), nil
|
return ioutil.NopCloser(strings.NewReader("")), nil
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
if tc.deferredFunc != nil {
|
if tc.deferredFunc != nil {
|
||||||
|
|
|
@ -19,7 +19,7 @@ func TestCliNewTagCommandErrors(t *testing.T) {
|
||||||
for _, args := range testCases {
|
for _, args := range testCases {
|
||||||
cmd := NewTagCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := NewTagCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetArgs(args)
|
cmd.SetArgs(args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), expectedError)
|
assert.ErrorContains(t, cmd.Execute(), expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ func TestCliNewTagCommand(t *testing.T) {
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
cmd.SetArgs([]string{"image1", "image2"})
|
cmd.SetArgs([]string{"image1", "image2"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
value, _ := cmd.Flags().GetBool("interspersed")
|
value, _ := cmd.Flags().GetBool("interspersed")
|
||||||
assert.Check(t, !value)
|
assert.Check(t, !value)
|
||||||
|
|
|
@ -33,7 +33,7 @@ func TestManifestAnnotateError(t *testing.T) {
|
||||||
cli := test.NewFakeCli(nil)
|
cli := test.NewFakeCli(nil)
|
||||||
cmd := newAnnotateCommand(cli)
|
cmd := newAnnotateCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ func TestManifestAnnotate(t *testing.T) {
|
||||||
|
|
||||||
cmd := newAnnotateCommand(cli)
|
cmd := newAnnotateCommand(cli)
|
||||||
cmd.SetArgs([]string{"example.com/list:v1", "example.com/fake:0.0"})
|
cmd.SetArgs([]string{"example.com/list:v1", "example.com/fake:0.0"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
expectedError := "manifest for image example.com/fake:0.0 does not exist"
|
expectedError := "manifest for image example.com/fake:0.0 does not exist"
|
||||||
assert.ErrorContains(t, cmd.Execute(), expectedError)
|
assert.ErrorContains(t, cmd.Execute(), expectedError)
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ func TestManifestCreateErrors(t *testing.T) {
|
||||||
cli := test.NewFakeCli(nil)
|
cli := test.NewFakeCli(nil)
|
||||||
cmd := newCreateListCommand(cli)
|
cmd := newCreateListCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ func TestManifestCreateAmend(t *testing.T) {
|
||||||
cmd := newCreateListCommand(cli)
|
cmd := newCreateListCommand(cli)
|
||||||
cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.1"})
|
cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.1"})
|
||||||
cmd.Flags().Set("amend", "true")
|
cmd.Flags().Set("amend", "true")
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
err = cmd.Execute()
|
err = cmd.Execute()
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ func TestManifestCreateRefuseAmend(t *testing.T) {
|
||||||
|
|
||||||
cmd := newCreateListCommand(cli)
|
cmd := newCreateListCommand(cli)
|
||||||
cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"})
|
cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
err = cmd.Execute()
|
err = cmd.Execute()
|
||||||
assert.Error(t, 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")
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ func TestManifestCreateNoManifest(t *testing.T) {
|
||||||
|
|
||||||
cmd := newCreateListCommand(cli)
|
cmd := newCreateListCommand(cli)
|
||||||
cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"})
|
cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.Error(t, err, "No such image: example.com/alpine:3.0")
|
assert.Error(t, err, "No such image: example.com/alpine:3.0")
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ func TestInspectCommandLocalManifestNotFound(t *testing.T) {
|
||||||
cli.SetManifestStore(store)
|
cli.SetManifestStore(store)
|
||||||
|
|
||||||
cmd := newInspectCommand(cli)
|
cmd := newInspectCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"})
|
cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"})
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.Error(t, err, "No such manifest: example.com/alpine:3.0")
|
assert.Error(t, err, "No such manifest: example.com/alpine:3.0")
|
||||||
|
@ -99,7 +99,7 @@ func TestInspectCommandNotFound(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := newInspectCommand(cli)
|
cmd := newInspectCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs([]string{"example.com/alpine:3.0"})
|
cmd.SetArgs([]string{"example.com/alpine:3.0"})
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.Error(t, err, "No such manifest: example.com/alpine:3.0")
|
assert.Error(t, err, "No such manifest: example.com/alpine:3.0")
|
||||||
|
@ -137,7 +137,7 @@ func TestInspectcommandRemoteManifest(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := newInspectCommand(cli)
|
cmd := newInspectCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs([]string{"example.com/alpine:3.0"})
|
cmd.SetArgs([]string{"example.com/alpine:3.0"})
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
actual := cli.OutBuffer()
|
actual := cli.OutBuffer()
|
||||||
|
|
|
@ -42,7 +42,7 @@ func TestManifestPushErrors(t *testing.T) {
|
||||||
cli := test.NewFakeCli(nil)
|
cli := test.NewFakeCli(nil)
|
||||||
cmd := newPushListCommand(cli)
|
cmd := newPushListCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func TestNetworkConnectErrors(t *testing.T) {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ func TestNetworkCreateErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
assert.NilError(t, cmd.Flags().Set(key, value))
|
assert.NilError(t, cmd.Flags().Set(key, value))
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ func TestNetworkDisconnectErrors(t *testing.T) {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ func TestNetworkListErrors(t *testing.T) {
|
||||||
networkListFunc: tc.networkListFunc,
|
networkListFunc: tc.networkListFunc,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ func TestNodeDemoteErrors(t *testing.T) {
|
||||||
nodeUpdateFunc: tc.nodeUpdateFunc,
|
nodeUpdateFunc: tc.nodeUpdateFunc,
|
||||||
}))
|
}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ func TestNodeInspectErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) {
|
||||||
infoFunc: tc.infoFunc,
|
infoFunc: tc.infoFunc,
|
||||||
})
|
})
|
||||||
cmd := newListCommand(cli)
|
cmd := newListCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.Error(t, cmd.Execute(), tc.expectedError)
|
assert.Error(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ func TestNodePromoteErrors(t *testing.T) {
|
||||||
nodeUpdateFunc: tc.nodeUpdateFunc,
|
nodeUpdateFunc: tc.nodeUpdateFunc,
|
||||||
}))
|
}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ func TestNodePsErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.Error(t, cmd.Execute(), tc.expectedError)
|
assert.Error(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ func TestNodeRemoveErrors(t *testing.T) {
|
||||||
nodeRemoveFunc: tc.nodeRemoveFunc,
|
nodeRemoveFunc: tc.nodeRemoveFunc,
|
||||||
}))
|
}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ func TestNodeUpdateErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ func TestCreateErrors(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := newCreateCommand(cli)
|
cmd := newCreateCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ func TestCreateErrorOnFileAsContextDir(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := newCreateCommand(cli)
|
cmd := newCreateCommand(cli)
|
||||||
cmd.SetArgs([]string{"plugin-foo", tmpFile.Path()})
|
cmd.SetArgs([]string{"plugin-foo", tmpFile.Path()})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), "context must be a directory")
|
assert.ErrorContains(t, cmd.Execute(), "context must be a directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ func TestCreateErrorOnContextDirWithoutConfig(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := newCreateCommand(cli)
|
cmd := newCreateCommand(cli)
|
||||||
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
|
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
|
|
||||||
expectedErr := "config.json: no such file or directory"
|
expectedErr := "config.json: no such file or directory"
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
|
@ -82,7 +82,7 @@ func TestCreateErrorOnInvalidConfig(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := newCreateCommand(cli)
|
cmd := newCreateCommand(cli)
|
||||||
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
|
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), "invalid")
|
assert.ErrorContains(t, cmd.Execute(), "invalid")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ func TestCreateErrorFromDaemon(t *testing.T) {
|
||||||
|
|
||||||
cmd := newCreateCommand(cli)
|
cmd := newCreateCommand(cli)
|
||||||
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
|
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), "Error creating plugin")
|
assert.ErrorContains(t, cmd.Execute(), "Error creating plugin")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ func TestPluginDisableErrors(t *testing.T) {
|
||||||
pluginDisableFunc: tc.pluginDisableFunc,
|
pluginDisableFunc: tc.pluginDisableFunc,
|
||||||
}))
|
}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ func TestPluginEnableErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ func TestInspectErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ func TestInstallErrors(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{pluginInstallFunc: tc.installFunc})
|
cli := test.NewFakeCli(&fakeClient{pluginInstallFunc: tc.installFunc})
|
||||||
cmd := newInstallCommand(cli)
|
cmd := newInstallCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ func TestInstallContentTrustErrors(t *testing.T) {
|
||||||
cli.SetNotaryClient(tc.notaryFunc)
|
cli.SetNotaryClient(tc.notaryFunc)
|
||||||
cmd := newInstallCommand(cli)
|
cmd := newInstallCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ func TestListErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func TestRemoveErrors(t *testing.T) {
|
||||||
})
|
})
|
||||||
cmd := newRemoveCommand(cli)
|
cmd := newRemoveCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ func TestSecretCreateErrors(t *testing.T) {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ func TestSecretInspectErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ func TestSecretListErrors(t *testing.T) {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ func TestSecretRemoveErrors(t *testing.T) {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ func TestSecretRemoveContinueAfterError(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd := newSecretRemoveCommand(cli)
|
cmd := newSecretRemoveCommand(cli)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs(names)
|
cmd.SetArgs(names)
|
||||||
assert.Error(t, cmd.Execute(), "error removing secret: foo")
|
assert.Error(t, cmd.Execute(), "error removing secret: foo")
|
||||||
assert.Check(t, is.DeepEqual(names, removedSecrets))
|
assert.Check(t, is.DeepEqual(names, removedSecrets))
|
||||||
|
|
|
@ -49,7 +49,7 @@ func TestRollback(t *testing.T) {
|
||||||
cmd := newRollbackCommand(cli)
|
cmd := newRollbackCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.Flags().Set("quiet", "true")
|
cmd.Flags().Set("quiet", "true")
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
assert.Check(t, is.Equal(strings.TrimSpace(cli.ErrBuffer().String()), tc.expectedDockerCliErr))
|
assert.Check(t, is.Equal(strings.TrimSpace(cli.ErrBuffer().String()), tc.expectedDockerCliErr))
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ func TestRollbackWithErrors(t *testing.T) {
|
||||||
}))
|
}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.Flags().Set("quiet", "true")
|
cmd.Flags().Set("quiet", "true")
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
func TestDeployWithEmptyName(t *testing.T) {
|
func TestDeployWithEmptyName(t *testing.T) {
|
||||||
cmd := newDeployCommand(test.NewFakeCli(&fakeClient{}), nil)
|
cmd := newDeployCommand(test.NewFakeCli(&fakeClient{}), nil)
|
||||||
cmd.SetArgs([]string{"' '"})
|
cmd.SetArgs([]string{"' '"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
|
|
||||||
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
|
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ func TestListErrors(t *testing.T) {
|
||||||
serviceListFunc: tc.serviceListFunc,
|
serviceListFunc: tc.serviceListFunc,
|
||||||
}), &orchestrator)
|
}), &orchestrator)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ func TestStackPsErrors(t *testing.T) {
|
||||||
taskListFunc: tc.taskListFunc,
|
taskListFunc: tc.taskListFunc,
|
||||||
}), &orchestrator)
|
}), &orchestrator)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ func TestStackPs(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
|
|
||||||
if tc.expectedErr != "" {
|
if tc.expectedErr != "" {
|
||||||
assert.Error(t, cmd.Execute(), tc.expectedErr)
|
assert.Error(t, cmd.Execute(), tc.expectedErr)
|
||||||
|
|
|
@ -44,7 +44,7 @@ func fakeClientForRemoveStackTest(version string) *fakeClient {
|
||||||
func TestRemoveWithEmptyName(t *testing.T) {
|
func TestRemoveWithEmptyName(t *testing.T) {
|
||||||
cmd := newRemoveCommand(test.NewFakeCli(&fakeClient{}), &orchestrator)
|
cmd := newRemoveCommand(test.NewFakeCli(&fakeClient{}), &orchestrator)
|
||||||
cmd.SetArgs([]string{"good", "' '", "alsogood"})
|
cmd.SetArgs([]string{"good", "' '", "alsogood"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
|
|
||||||
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
|
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ func TestRemoveContinueAfterError(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd := newRemoveCommand(test.NewFakeCli(cli), &orchestrator)
|
cmd := newRemoveCommand(test.NewFakeCli(cli), &orchestrator)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.SetArgs([]string{"foo", "bar"})
|
cmd.SetArgs([]string{"foo", "bar"})
|
||||||
|
|
||||||
assert.Error(t, cmd.Execute(), "Failed to remove some resources from stack: foo")
|
assert.Error(t, cmd.Execute(), "Failed to remove some resources from stack: foo")
|
||||||
|
|
|
@ -79,7 +79,7 @@ func TestStackServicesErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ func TestStackServicesErrors(t *testing.T) {
|
||||||
func TestRunServicesWithEmptyName(t *testing.T) {
|
func TestRunServicesWithEmptyName(t *testing.T) {
|
||||||
cmd := newServicesCommand(test.NewFakeCli(&fakeClient{}), &orchestrator)
|
cmd := newServicesCommand(test.NewFakeCli(&fakeClient{}), &orchestrator)
|
||||||
cmd.SetArgs([]string{"' '"})
|
cmd.SetArgs([]string{"' '"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
|
|
||||||
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
|
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ func TestDisplayTrustRootInvalidFlags(t *testing.T) {
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
assert.Check(t, cmd.Flags().Parse(testCase.args))
|
assert.Check(t, cmd.Flags().Parse(testCase.args))
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), testCase.errorMsg)
|
assert.ErrorContains(t, cmd.Execute(), testCase.errorMsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ func TestUpdateSwarmSpecDefaultRotate(t *testing.T) {
|
||||||
})
|
})
|
||||||
cmd := newCACommand(cli)
|
cmd := newCACommand(cli)
|
||||||
cmd.SetArgs([]string{"--rotate", "--detach"})
|
cmd.SetArgs([]string{"--rotate", "--detach"})
|
||||||
cmd.SetOutput(cli.OutBuffer())
|
cmd.SetOut(cli.OutBuffer())
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
|
|
||||||
expected := swarmSpecWithFullCAConfig()
|
expected := swarmSpecWithFullCAConfig()
|
||||||
|
@ -218,7 +218,7 @@ func TestUpdateSwarmSpecCertAndKey(t *testing.T) {
|
||||||
"--ca-cert=" + certfile,
|
"--ca-cert=" + certfile,
|
||||||
"--ca-key=" + keyfile,
|
"--ca-key=" + keyfile,
|
||||||
"--cert-expiry=3m"})
|
"--cert-expiry=3m"})
|
||||||
cmd.SetOutput(cli.OutBuffer())
|
cmd.SetOut(cli.OutBuffer())
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
|
|
||||||
expected := swarmSpecWithFullCAConfig()
|
expected := swarmSpecWithFullCAConfig()
|
||||||
|
@ -244,7 +244,7 @@ func TestUpdateSwarmSpecCertAndExternalCA(t *testing.T) {
|
||||||
"--detach",
|
"--detach",
|
||||||
"--ca-cert=" + certfile,
|
"--ca-cert=" + certfile,
|
||||||
"--external-ca=protocol=cfssl,url=https://some.external.ca"})
|
"--external-ca=protocol=cfssl,url=https://some.external.ca"})
|
||||||
cmd.SetOutput(cli.OutBuffer())
|
cmd.SetOut(cli.OutBuffer())
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
|
|
||||||
expected := swarmSpecWithFullCAConfig()
|
expected := swarmSpecWithFullCAConfig()
|
||||||
|
@ -282,7 +282,7 @@ func TestUpdateSwarmSpecCertAndKeyAndExternalCA(t *testing.T) {
|
||||||
"--ca-cert=" + certfile,
|
"--ca-cert=" + certfile,
|
||||||
"--ca-key=" + keyfile,
|
"--ca-key=" + keyfile,
|
||||||
"--external-ca=protocol=cfssl,url=https://some.external.ca"})
|
"--external-ca=protocol=cfssl,url=https://some.external.ca"})
|
||||||
cmd.SetOutput(cli.OutBuffer())
|
cmd.SetOut(cli.OutBuffer())
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
|
|
||||||
expected := swarmSpecWithFullCAConfig()
|
expected := swarmSpecWithFullCAConfig()
|
||||||
|
|
|
@ -73,7 +73,7 @@ func TestSwarmInitErrorOnAPIFailure(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.Error(t, cmd.Execute(), tc.expectedError)
|
assert.Error(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ func TestSwarmJoinErrors(t *testing.T) {
|
||||||
infoFunc: tc.infoFunc,
|
infoFunc: tc.infoFunc,
|
||||||
}))
|
}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func TestSwarmLeaveErrors(t *testing.T) {
|
||||||
swarmLeaveFunc: tc.swarmLeaveFunc,
|
swarmLeaveFunc: tc.swarmLeaveFunc,
|
||||||
}))
|
}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ func TestSwarmUnlockKeyErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ func TestSwarmUnlockErrors(t *testing.T) {
|
||||||
swarmUnlockFunc: tc.swarmUnlockFunc,
|
swarmUnlockFunc: tc.swarmUnlockFunc,
|
||||||
}))
|
}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ func TestSwarmUpdateErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ func TestSwarmUpdate(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(cli.OutBuffer())
|
cmd.SetOut(cli.OutBuffer())
|
||||||
assert.NilError(t, cmd.Execute())
|
assert.NilError(t, cmd.Execute())
|
||||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("update-%s.golden", tc.name))
|
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("update-%s.golden", tc.name))
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ func TestVersionWithoutServer(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewVersionCommand(cli)
|
cmd := NewVersionCommand(cli)
|
||||||
cmd.SetOutput(cli.Err())
|
cmd.SetOut(cli.Err())
|
||||||
assert.ErrorContains(t, cmd.Execute(), "no server")
|
assert.ErrorContains(t, cmd.Execute(), "no server")
|
||||||
out := cli.OutBuffer().String()
|
out := cli.OutBuffer().String()
|
||||||
// TODO: use an assertion like e2e/image/build_test.go:assertBuildOutput()
|
// TODO: use an assertion like e2e/image/build_test.go:assertBuildOutput()
|
||||||
|
|
|
@ -65,7 +65,7 @@ func TestTrustInspectPrettyCommandErrors(t *testing.T) {
|
||||||
cmd := newInspectCommand(
|
cmd := newInspectCommand(
|
||||||
test.NewFakeCli(&fakeClient{}))
|
test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.Flags().Set("pretty", "true")
|
cmd.Flags().Set("pretty", "true")
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ func TestTrustInspectPrettyCommandOfflineErrors(t *testing.T) {
|
||||||
cmd := newInspectCommand(cli)
|
cmd := newInspectCommand(cli)
|
||||||
cmd.Flags().Set("pretty", "true")
|
cmd.Flags().Set("pretty", "true")
|
||||||
cmd.SetArgs([]string{"nonexistent-reg-name.io/image"})
|
cmd.SetArgs([]string{"nonexistent-reg-name.io/image"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access nonexistent-reg-name.io/image")
|
assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access nonexistent-reg-name.io/image")
|
||||||
|
|
||||||
cli = test.NewFakeCli(&fakeClient{})
|
cli = test.NewFakeCli(&fakeClient{})
|
||||||
|
@ -85,7 +85,7 @@ func TestTrustInspectPrettyCommandOfflineErrors(t *testing.T) {
|
||||||
cmd = newInspectCommand(cli)
|
cmd = newInspectCommand(cli)
|
||||||
cmd.Flags().Set("pretty", "true")
|
cmd.Flags().Set("pretty", "true")
|
||||||
cmd.SetArgs([]string{"nonexistent-reg-name.io/image:tag"})
|
cmd.SetArgs([]string{"nonexistent-reg-name.io/image:tag"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access nonexistent-reg-name.io/image")
|
assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access nonexistent-reg-name.io/image")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ func TestTrustInspectPrettyCommandUninitializedErrors(t *testing.T) {
|
||||||
cmd := newInspectCommand(cli)
|
cmd := newInspectCommand(cli)
|
||||||
cmd.Flags().Set("pretty", "true")
|
cmd.Flags().Set("pretty", "true")
|
||||||
cmd.SetArgs([]string{"reg/unsigned-img"})
|
cmd.SetArgs([]string{"reg/unsigned-img"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access reg/unsigned-img")
|
assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access reg/unsigned-img")
|
||||||
|
|
||||||
cli = test.NewFakeCli(&fakeClient{})
|
cli = test.NewFakeCli(&fakeClient{})
|
||||||
|
@ -103,7 +103,7 @@ func TestTrustInspectPrettyCommandUninitializedErrors(t *testing.T) {
|
||||||
cmd = newInspectCommand(cli)
|
cmd = newInspectCommand(cli)
|
||||||
cmd.Flags().Set("pretty", "true")
|
cmd.Flags().Set("pretty", "true")
|
||||||
cmd.SetArgs([]string{"reg/unsigned-img:tag"})
|
cmd.SetArgs([]string{"reg/unsigned-img:tag"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access reg/unsigned-img:tag")
|
assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access reg/unsigned-img:tag")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ func TestTrustInspectPrettyCommandEmptyNotaryRepoErrors(t *testing.T) {
|
||||||
cmd := newInspectCommand(cli)
|
cmd := newInspectCommand(cli)
|
||||||
cmd.Flags().Set("pretty", "true")
|
cmd.Flags().Set("pretty", "true")
|
||||||
cmd.SetArgs([]string{"reg/img:unsigned-tag"})
|
cmd.SetArgs([]string{"reg/img:unsigned-tag"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.NilError(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(), "No signatures for reg/img:unsigned-tag"))
|
||||||
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Administrative keys for reg/img"))
|
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Administrative keys for reg/img"))
|
||||||
|
@ -123,7 +123,7 @@ func TestTrustInspectPrettyCommandEmptyNotaryRepoErrors(t *testing.T) {
|
||||||
cmd = newInspectCommand(cli)
|
cmd = newInspectCommand(cli)
|
||||||
cmd.Flags().Set("pretty", "true")
|
cmd.Flags().Set("pretty", "true")
|
||||||
cmd.SetArgs([]string{"reg/img"})
|
cmd.SetArgs([]string{"reg/img"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.NilError(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(), "No signatures for reg/img"))
|
||||||
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Administrative keys for reg/img"))
|
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Administrative keys for reg/img"))
|
||||||
|
|
|
@ -38,7 +38,7 @@ func TestTrustInspectCommandErrors(t *testing.T) {
|
||||||
test.NewFakeCli(&fakeClient{}))
|
test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.Flags().Set("pretty", "true")
|
cmd.Flags().Set("pretty", "true")
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ func TestTrustInspectCommandRepositoryErrors(t *testing.T) {
|
||||||
cli.SetNotaryClient(tc.notaryRepository)
|
cli.SetNotaryClient(tc.notaryRepository)
|
||||||
cmd := newInspectCommand(cli)
|
cmd := newInspectCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.err)
|
assert.ErrorContains(t, cmd.Execute(), tc.err)
|
||||||
if tc.golden != "" {
|
if tc.golden != "" {
|
||||||
golden.Assert(t, cli.OutBuffer().String(), tc.golden)
|
golden.Assert(t, cli.OutBuffer().String(), tc.golden)
|
||||||
|
|
|
@ -44,7 +44,7 @@ func TestTrustKeyGenerateErrors(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := newKeyGenerateCommand(cli)
|
cmd := newKeyGenerateCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ func TestTrustKeyLoadErrors(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := newKeyLoadCommand(cli)
|
cmd := newKeyLoadCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
assert.Check(t, is.Contains(cli.OutBuffer().String(), tc.expectedOutput))
|
assert.Check(t, is.Contains(cli.OutBuffer().String(), tc.expectedOutput))
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ func TestTrustRevokeCommandErrors(t *testing.T) {
|
||||||
cmd := newRevokeCommand(
|
cmd := newRevokeCommand(
|
||||||
test.NewFakeCli(&fakeClient{}))
|
test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ func TestTrustRevokeCommand(t *testing.T) {
|
||||||
cli.SetNotaryClient(tc.notaryRepository)
|
cli.SetNotaryClient(tc.notaryRepository)
|
||||||
cmd := newRevokeCommand(cli)
|
cmd := newRevokeCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
if tc.expectedErr != "" {
|
if tc.expectedErr != "" {
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedErr)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedErr)
|
||||||
return
|
return
|
||||||
|
|
|
@ -70,7 +70,7 @@ func TestTrustSignCommandErrors(t *testing.T) {
|
||||||
cmd := newSignCommand(
|
cmd := newSignCommand(
|
||||||
test.NewFakeCli(&fakeClient{}))
|
test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ func TestTrustSignCommandOfflineErrors(t *testing.T) {
|
||||||
cli.SetNotaryClient(notaryfake.GetOfflineNotaryRepository)
|
cli.SetNotaryClient(notaryfake.GetOfflineNotaryRepository)
|
||||||
cmd := newSignCommand(cli)
|
cmd := newSignCommand(cli)
|
||||||
cmd.SetArgs([]string{"reg-name.io/image:tag"})
|
cmd.SetArgs([]string{"reg-name.io/image:tag"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), "client is offline")
|
assert.ErrorContains(t, cmd.Execute(), "client is offline")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ func TestSignCommandChangeListIsCleanedOnError(t *testing.T) {
|
||||||
cli.SetNotaryClient(notaryfake.GetLoadedNotaryRepository)
|
cli.SetNotaryClient(notaryfake.GetLoadedNotaryRepository)
|
||||||
cmd := newSignCommand(cli)
|
cmd := newSignCommand(cli)
|
||||||
cmd.SetArgs([]string{"ubuntu:latest"})
|
cmd.SetArgs([]string{"ubuntu:latest"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
|
|
||||||
err = cmd.Execute()
|
err = cmd.Execute()
|
||||||
assert.Assert(t, err != nil)
|
assert.Assert(t, err != nil)
|
||||||
|
@ -303,7 +303,7 @@ func TestSignCommandLocalFlag(t *testing.T) {
|
||||||
cli.SetNotaryClient(notaryfake.GetEmptyTargetsNotaryRepository)
|
cli.SetNotaryClient(notaryfake.GetEmptyTargetsNotaryRepository)
|
||||||
cmd := newSignCommand(cli)
|
cmd := newSignCommand(cli)
|
||||||
cmd.SetArgs([]string{"--local", "reg-name.io/image:red"})
|
cmd.SetArgs([]string{"--local", "reg-name.io/image:red"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), "error contacting notary server: dial tcp: lookup reg-name.io")
|
assert.ErrorContains(t, cmd.Execute(), "error contacting notary server: dial tcp: lookup reg-name.io")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ func TestTrustSignerAddErrors(t *testing.T) {
|
||||||
cli.SetNotaryClient(notaryfake.GetOfflineNotaryRepository)
|
cli.SetNotaryClient(notaryfake.GetOfflineNotaryRepository)
|
||||||
cmd := newSignerAddCommand(cli)
|
cmd := newSignerAddCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ func TestSignerAddCommandNoTargetsKey(t *testing.T) {
|
||||||
cmd := newSignerAddCommand(cli)
|
cmd := newSignerAddCommand(cli)
|
||||||
cmd.SetArgs([]string{"--key", tmpfile.Name(), "alice", "alpine", "linuxkit/alpine"})
|
cmd.SetArgs([]string{"--key", tmpfile.Name(), "alice", "alpine", "linuxkit/alpine"})
|
||||||
|
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.Error(t, 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()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ func TestSignerAddCommandBadKeyPath(t *testing.T) {
|
||||||
cmd := newSignerAddCommand(cli)
|
cmd := newSignerAddCommand(cli)
|
||||||
cmd.SetArgs([]string{"--key", "/path/to/key.pem", "alice", "alpine"})
|
cmd.SetArgs([]string{"--key", "/path/to/key.pem", "alice", "alpine"})
|
||||||
|
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
expectedError := "unable to read public key from file: open /path/to/key.pem: no such file or directory"
|
expectedError := "unable to read public key from file: open /path/to/key.pem: no such file or directory"
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
expectedError = "unable to read public key from file: open /path/to/key.pem: The system cannot find the path specified."
|
expectedError = "unable to read public key from file: open /path/to/key.pem: The system cannot find the path specified."
|
||||||
|
@ -123,7 +123,7 @@ func TestSignerAddCommandInvalidRepoName(t *testing.T) {
|
||||||
imageName := "870d292919d01a0af7e7f056271dc78792c05f55f49b9b9012b6d89725bd9abd"
|
imageName := "870d292919d01a0af7e7f056271dc78792c05f55f49b9b9012b6d89725bd9abd"
|
||||||
cmd.SetArgs([]string{"--key", pubKeyFilepath, "alice", imageName})
|
cmd.SetArgs([]string{"--key", pubKeyFilepath, "alice", imageName})
|
||||||
|
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.Error(t, 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)
|
expectedErr := fmt.Sprintf("invalid repository name (%s), cannot specify 64-byte hexadecimal strings\n\n", imageName)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ func TestTrustSignerRemoveErrors(t *testing.T) {
|
||||||
cmd := newSignerRemoveCommand(
|
cmd := newSignerRemoveCommand(
|
||||||
test.NewFakeCli(&fakeClient{}))
|
test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
testCasesWithOutput := []struct {
|
testCasesWithOutput := []struct {
|
||||||
|
@ -61,7 +61,7 @@ func TestTrustSignerRemoveErrors(t *testing.T) {
|
||||||
cli.SetNotaryClient(notaryfake.GetOfflineNotaryRepository)
|
cli.SetNotaryClient(notaryfake.GetOfflineNotaryRepository)
|
||||||
cmd := newSignerRemoveCommand(cli)
|
cmd := newSignerRemoveCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
cmd.Execute()
|
cmd.Execute()
|
||||||
assert.Check(t, is.Contains(cli.ErrBuffer().String(), tc.expectedError))
|
assert.Check(t, is.Contains(cli.ErrBuffer().String(), tc.expectedError))
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ func TestVolumeCreateErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ func TestVolumeInspectErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ func TestVolumeListErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ func TestVolumePruneErrors(t *testing.T) {
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ func TestVolumeRemoveErrors(t *testing.T) {
|
||||||
volumeRemoveFunc: tc.volumeRemoveFunc,
|
volumeRemoveFunc: tc.volumeRemoveFunc,
|
||||||
}))
|
}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ func runTestCases(t *testing.T, testCases []testCase) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cmd := newDummyCommand(tc.validateFunc)
|
cmd := newDummyCommand(tc.validateFunc)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOut(ioutil.Discard)
|
||||||
|
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
assert.ErrorContains(t, err, tc.expectedError)
|
assert.ErrorContains(t, err, tc.expectedError)
|
||||||
|
|
|
@ -59,7 +59,7 @@ func newDockerCommand(dockerCli *command.DockerCli) *cli.TopLevelCommand {
|
||||||
setupHelpCommand(dockerCli, cmd, helpCmd)
|
setupHelpCommand(dockerCli, cmd, helpCmd)
|
||||||
setHelpFunc(dockerCli, cmd)
|
setHelpFunc(dockerCli, cmd)
|
||||||
|
|
||||||
cmd.SetOutput(dockerCli.Out())
|
cmd.SetOut(dockerCli.Out())
|
||||||
commands.AddCommands(cmd, dockerCli)
|
commands.AddCommands(cmd, dockerCli)
|
||||||
|
|
||||||
cli.DisableFlagsInUseLine(cmd)
|
cli.DisableFlagsInUseLine(cmd)
|
||||||
|
|
Loading…
Reference in New Issue