Files
moby/cmd/dockerd/debug/debug_test.go
Sebastiaan van Stijn d469079338 cmd: remove // import comments
These comments were added to enforce using the correct import path for
our packages ("github.com/docker/docker", not "github.com/moby/moby").
However, when working in go module mode (not GOPATH / vendor), they have
no effect, so their impact is limited.

Remove these imports in preparation of migrating our code to become an
actual go module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-30 15:59:11 +02:00

44 lines
869 B
Go

package 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")
}
}