2016-02-01 18:09:25 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
|
|
"github.com/docker/docker/utils"
|
2016-06-22 13:08:04 -04:00
|
|
|
|
2016-09-08 13:11:39 -04:00
|
|
|
"github.com/docker/docker/cli/command"
|
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
|
|
|
|
|
|
|
if err := cmd.PersistentPreRunE(cmd, []string{}); err != nil {
|
|
|
|
t.Fatalf("Unexpected error: %s", err.Error())
|
|
|
|
}
|
2016-02-01 18:09:25 -05:00
|
|
|
|
|
|
|
if os.Getenv("DEBUG") != "1" {
|
|
|
|
t.Fatal("expected debug enabled, got false")
|
|
|
|
}
|
|
|
|
if logrus.GetLevel() != logrus.DebugLevel {
|
|
|
|
t.Fatalf("expected logrus debug level, got %v", logrus.GetLevel())
|
|
|
|
}
|
|
|
|
}
|