2016-02-01 18:09:25 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-11-15 11:18:33 -05:00
|
|
|
"io/ioutil"
|
2016-02-01 18:09:25 -05:00
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
2016-09-08 13:11:39 -04:00
|
|
|
"github.com/docker/docker/cli/command"
|
2016-11-15 11:18:33 -05:00
|
|
|
"github.com/docker/docker/pkg/testutil/assert"
|
|
|
|
"github.com/docker/docker/utils"
|
2016-02-01 18:09:25 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestClientDebugEnabled(t *testing.T) {
|
|
|
|
defer utils.DisableDebug()
|
|
|
|
|
2016-09-08 13:11:39 -04:00
|
|
|
cmd := newDockerCommand(&command.DockerCli{})
|
2016-06-22 18:36:51 -04:00
|
|
|
cmd.Flags().Set("debug", "true")
|
2016-06-22 13:08:04 -04:00
|
|
|
|
2016-11-15 11:18:33 -05:00
|
|
|
err := cmd.PersistentPreRunE(cmd, []string{})
|
|
|
|
assert.NilError(t, err)
|
|
|
|
assert.Equal(t, os.Getenv("DEBUG"), "1")
|
|
|
|
assert.Equal(t, logrus.GetLevel(), logrus.DebugLevel)
|
|
|
|
}
|
2016-02-01 18:09:25 -05:00
|
|
|
|
2016-11-15 11:18:33 -05:00
|
|
|
func TestExitStatusForInvalidSubcommandWithHelpFlag(t *testing.T) {
|
|
|
|
discard := ioutil.Discard
|
|
|
|
cmd := newDockerCommand(command.NewDockerCli(os.Stdin, discard, discard))
|
|
|
|
cmd.SetArgs([]string{"help", "invalid"})
|
|
|
|
err := cmd.Execute()
|
|
|
|
assert.Error(t, err, "unknown help topic: invalid")
|
2016-02-01 18:09:25 -05:00
|
|
|
}
|