From aa74f278667c29752d71071503098cf71988c054 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Sun, 5 Mar 2017 15:25:11 +1100 Subject: [PATCH] cmd: docker: fix TestDaemonCommand In more recent versions of Cobra, `--help` parsing is done before anything else resulting in TestDaemonCommand not actually passing. I'm actually unsure if this test ever passed since it appears that !daemon is not being run as part of the test suite. Signed-off-by: Aleksa Sarai --- daemon_none.go | 6 ++++-- daemon_none_test.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/daemon_none.go b/daemon_none.go index 65f9f37be2..6fbd000125 100644 --- a/daemon_none.go +++ b/daemon_none.go @@ -12,8 +12,10 @@ import ( func newDaemonCommand() *cobra.Command { return &cobra.Command{ - Use: "daemon", - Hidden: true, + Use: "daemon", + Hidden: true, + Args: cobra.ArbitraryArgs, + DisableFlagParsing: true, RunE: func(cmd *cobra.Command, args []string) error { return runDaemon() }, diff --git a/daemon_none_test.go b/daemon_none_test.go index 32032fe1b3..bd42add986 100644 --- a/daemon_none_test.go +++ b/daemon_none_test.go @@ -10,7 +10,7 @@ import ( func TestDaemonCommand(t *testing.T) { cmd := newDaemonCommand() - cmd.SetArgs([]string{"--help"}) + cmd.SetArgs([]string{"--version"}) err := cmd.Execute() assert.Error(t, err, "Please run `dockerd`")