mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix daemon command proxy.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
91ec7fa811
commit
a594cd8991
3 changed files with 41 additions and 12 deletions
|
@ -3,18 +3,15 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/pkg/testutil/assert"
|
||||
)
|
||||
|
||||
func TestCmdDaemon(t *testing.T) {
|
||||
proxy := NewDaemonProxy()
|
||||
err := proxy.CmdDaemon("--help")
|
||||
if err == nil {
|
||||
t.Fatal("Expected CmdDaemon to fail on Windows.")
|
||||
}
|
||||
func TestDaemonCommand(t *testing.T) {
|
||||
cmd := newDaemonCommand()
|
||||
cmd.SetArgs([]string{"--help"})
|
||||
err := cmd.Execute()
|
||||
|
||||
if !strings.Contains(err.Error(), "Please run `dockerd`") {
|
||||
t.Fatalf("Expected an error about running dockerd, got %s", err)
|
||||
}
|
||||
assert.Error(t, err, "Please run `dockerd`")
|
||||
}
|
||||
|
|
30
cmd/docker/daemon_unit_test.go
Normal file
30
cmd/docker/daemon_unit_test.go
Normal file
|
@ -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{
|
||||
Use: "daemon",
|
||||
Hidden: true,
|
||||
Args: cobra.ArbitraryArgs,
|
||||
DisableFlagParsing: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runDaemon()
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue