moby/cli/debug/debug_test.go
Sebastiaan van Stijn c3d533f37f
cli/debug: use string-literals for easier grep'ing
Also removed some newlines from t.Fatal() as they shouldn't be needed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:27:00 +02:00

43 lines
935 B
Go

package debug // import "github.com/docker/docker/cli/debug"
import (
"os"
"testing"
"github.com/sirupsen/logrus"
)
func TestEnable(t *testing.T) {
defer func() {
os.Setenv("DEBUG", "")
logrus.SetLevel(logrus.InfoLevel)
}()
Enable()
if os.Getenv("DEBUG") != "1" {
t.Fatalf("expected DEBUG=1, got %s", os.Getenv("DEBUG"))
}
if logrus.GetLevel() != logrus.DebugLevel {
t.Fatalf("expected log level %v, got %v", logrus.DebugLevel, logrus.GetLevel())
}
}
func TestDisable(t *testing.T) {
Disable()
if os.Getenv("DEBUG") != "" {
t.Fatalf(`expected DEBUG="", got %s`, os.Getenv("DEBUG"))
}
if logrus.GetLevel() != logrus.InfoLevel {
t.Fatalf("expected log level %v, got %v", logrus.InfoLevel, logrus.GetLevel())
}
}
func TestEnabled(t *testing.T) {
Enable()
if !IsEnabled() {
t.Fatal("expected debug enabled, got false")
}
Disable()
if IsEnabled() {
t.Fatal("expected debug disabled, got true")
}
}