mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
9f315dd328
- Add client debug info to the `docker info` command. Signed-off-by: David Calavera <david.calavera@gmail.com>
43 lines
943 B
Go
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")
|
|
}
|
|
}
|