moby/utils/debug_test.go
David Calavera 9f315dd328 Add regression tests for client debug flag.
- Add client debug info to the `docker info` command.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-02-02 16:57:36 -05:00

43 lines
943 B
Go

package utils
import (
"os"
"testing"
"github.com/Sirupsen/logrus"
)
func TestEnableDebug(t *testing.T) {
defer func() {
os.Setenv("DEBUG", "")
logrus.SetLevel(logrus.InfoLevel)
}()
EnableDebug()
if os.Getenv("DEBUG") != "1" {
t.Fatalf("expected DEBUG=1, got %s\n", os.Getenv("DEBUG"))
}
if logrus.GetLevel() != logrus.DebugLevel {
t.Fatalf("expected log level %v, got %v\n", logrus.DebugLevel, logrus.GetLevel())
}
}
func TestDisableDebug(t *testing.T) {
DisableDebug()
if os.Getenv("DEBUG") != "" {
t.Fatalf("expected DEBUG=\"\", got %s\n", os.Getenv("DEBUG"))
}
if logrus.GetLevel() != logrus.InfoLevel {
t.Fatalf("expected log level %v, got %v\n", logrus.InfoLevel, logrus.GetLevel())
}
}
func TestDebugEnabled(t *testing.T) {
EnableDebug()
if !IsDebugEnabled() {
t.Fatal("expected debug enabled, got false")
}
DisableDebug()
if IsDebugEnabled() {
t.Fatal("expected debug disabled, got true")
}
}