mirror of https://github.com/docker/cli.git
34 lines
906 B
Go
34 lines
906 B
Go
package main
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/docker/cli/cli/command"
|
|
"github.com/docker/cli/cli/debug"
|
|
"github.com/gotestyourself/gotestyourself/assert"
|
|
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func TestClientDebugEnabled(t *testing.T) {
|
|
defer debug.Disable()
|
|
|
|
cmd := newDockerCommand(&command.DockerCli{})
|
|
cmd.Flags().Set("debug", "true")
|
|
|
|
err := cmd.PersistentPreRunE(cmd, []string{})
|
|
assert.Check(t, err)
|
|
assert.Check(t, is.Equal("1", os.Getenv("DEBUG")))
|
|
assert.Check(t, is.Equal(logrus.DebugLevel, logrus.GetLevel()))
|
|
}
|
|
|
|
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.Check(t, is.Error(err, "unknown help topic: invalid"))
|
|
}
|