mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
ce37550347
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
32 lines
824 B
Go
32 lines
824 B
Go
package main
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
"github.com/docker/docker/cli/command"
|
|
"github.com/docker/docker/cli/debug"
|
|
"github.com/docker/docker/pkg/testutil/assert"
|
|
)
|
|
|
|
func TestClientDebugEnabled(t *testing.T) {
|
|
defer debug.Disable()
|
|
|
|
cmd := newDockerCommand(&command.DockerCli{})
|
|
cmd.Flags().Set("debug", "true")
|
|
|
|
err := cmd.PersistentPreRunE(cmd, []string{})
|
|
assert.NilError(t, err)
|
|
assert.Equal(t, os.Getenv("DEBUG"), "1")
|
|
assert.Equal(t, logrus.GetLevel(), logrus.DebugLevel)
|
|
}
|
|
|
|
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")
|
|
}
|