MCPcopy Create free account
hub / github.com/github/gh-aw / TestSpec_SlogIntegration_NewSlogLoggerWithHandler

Function TestSpec_SlogIntegration_NewSlogLoggerWithHandler

pkg/logger/spec_test.go:193–212  ·  view source on GitHub ↗

TestSpec_SlogIntegration_NewSlogLoggerWithHandler validates the convenience constructor. Spec section: "### NewSlogLoggerWithHandler(logger *Logger) *slog.Logger"

(t *testing.T)

Source from the content-addressed store, hash-verified

191// TestSpec_SlogIntegration_NewSlogLoggerWithHandler validates the convenience constructor.
192// Spec section: "### NewSlogLoggerWithHandler(logger *Logger) *slog.Logger"
193func TestSpec_SlogIntegration_NewSlogLoggerWithHandler(t *testing.T) {
194 t.Run("NewSlogLoggerWithHandler returns a non-nil slog.Logger", func(t *testing.T) {
195 // Spec: "Convenience constructor that creates both the SlogHandler and the slog.Logger in one call."
196 log := logger.New("spec:slog-convenience")
197 slogLogger := logger.NewSlogLoggerWithHandler(log)
198 require.NotNil(t, slogLogger, "NewSlogLoggerWithHandler should return a non-nil slog.Logger")
199 })
200
201 t.Run("resulting slog.Logger can log at any level without panic", func(t *testing.T) {
202 log := logger.New("spec:slog-levels")
203 slogLogger := logger.NewSlogLoggerWithHandler(log)
204 // Must not panic regardless of enabled state
205 assert.NotPanics(t, func() {
206 slogLogger.Info("info message", "key", "value")
207 slogLogger.Warn("warn message", "count", 42)
208 slogLogger.Error("error message")
209 slogLogger.Debug("debug message")
210 }, "slog.Logger methods should not panic")
211 })
212}
213
214// TestSpec_ThreadSafety_ConcurrentUse validates the documented thread-safety guarantee.
215// Spec section: "## Features — Thread-safe: Safe for concurrent use"

Callers

nothing calls this directly

Calls 4

NewFunction · 0.92
NewSlogLoggerWithHandlerFunction · 0.92
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected