moby/cli/debug/debug_test.go
Sebastiaan van Stijn cff4f20c44
migrate to github.com/containerd/log v0.1.0
The github.com/containerd/containerd/log package was moved to a separate
module, which will also be used by upcoming (patch) releases of containerd.

This patch moves our own uses of the package to use the new module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-11 17:52:23 +02:00

43 lines
916 B
Go

package debug // import "github.com/docker/docker/cli/debug"
import (
"os"
"testing"
"github.com/containerd/log"
)
func TestEnable(t *testing.T) {
t.Cleanup(func() {
_ = os.Setenv("DEBUG", "")
_ = log.SetLevel("info")
})
Enable()
if debug := os.Getenv("DEBUG"); debug != "1" {
t.Fatalf("expected DEBUG=1, got %s", debug)
}
if lvl := log.GetLevel(); lvl != log.DebugLevel {
t.Fatalf("expected log level %v, got %v", log.DebugLevel, lvl)
}
}
func TestDisable(t *testing.T) {
Disable()
if debug := os.Getenv("DEBUG"); debug != "" {
t.Fatalf(`expected DEBUG="", got %s`, debug)
}
if lvl := log.GetLevel(); lvl != log.InfoLevel {
t.Fatalf("expected log level %v, got %v", log.InfoLevel, lvl)
}
}
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")
}
}