package logging import ( "bytes" "log/slog" "strings" "testing" ) func TestNewLoggerWritesOutput(t *testing.T) { var buf bytes.Buffer logger := NewLogger(&buf, slog.LevelInfo) if logger == nil { t.Fatal("logger is nil") } logger.Info("hello", "component", "test") out := buf.String() if !strings.Contains(out, "hello") { t.Fatalf("output = %q, want to contain message", out) } } func TestNewLoggerNilWriter(t *testing.T) { logger := NewLogger(nil, slog.LevelInfo) if logger == nil { t.Fatal("logger is nil") } logger.Info("should not panic") }