mirror of https://github.com/docker/cli.git
Fix daemon command proxy.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
9af25060cd
commit
ad96b991e9
|
@ -3,18 +3,15 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/docker/docker/pkg/testutil/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCmdDaemon(t *testing.T) {
|
func TestDaemonCommand(t *testing.T) {
|
||||||
proxy := NewDaemonProxy()
|
cmd := newDaemonCommand()
|
||||||
err := proxy.CmdDaemon("--help")
|
cmd.SetArgs([]string{"--help"})
|
||||||
if err == nil {
|
err := cmd.Execute()
|
||||||
t.Fatal("Expected CmdDaemon to fail on Windows.")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !strings.Contains(err.Error(), "Please run `dockerd`") {
|
assert.Error(t, err, "Please run `dockerd`")
|
||||||
t.Fatalf("Expected an error about running dockerd, got %s", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
// +build daemon
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/docker/docker/pkg/testutil/assert"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func stubRun(cmd *cobra.Command, args []string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDaemonCommandHelp(t *testing.T) {
|
||||||
|
cmd := newDaemonCommand()
|
||||||
|
cmd.RunE = stubRun
|
||||||
|
cmd.SetArgs([]string{"--help"})
|
||||||
|
err := cmd.Execute()
|
||||||
|
assert.NilError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDaemonCommand(t *testing.T) {
|
||||||
|
cmd := newDaemonCommand()
|
||||||
|
cmd.RunE = stubRun
|
||||||
|
cmd.SetArgs([]string{"--containerd", "/foo"})
|
||||||
|
err := cmd.Execute()
|
||||||
|
assert.NilError(t, err)
|
||||||
|
}
|
|
@ -19,6 +19,8 @@ func newDaemonCommand() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "daemon",
|
Use: "daemon",
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
|
Args: cobra.ArbitraryArgs,
|
||||||
|
DisableFlagParsing: true,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
return runDaemon()
|
return runDaemon()
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue