Files
logging/log_test.go
T
argoyle a45c50ab7b
logging / coverage-baseline (pull_request) Has been skipped
logging / vulnerabilities (pull_request) Successful in 1m32s
logging / test (pull_request) Successful in 2m48s
pre-commit / pre-commit (pull_request) Successful in 5m27s
feat: move MockLogger into a logtest sub-package
NewMockLogger/MockLogger move from the main `logging` package to a new
`logging/logtest` sub-package, so the production `logging` package's import
graph no longer pulls in testify — only consumers that import logtest do.
testify stays in the module's go.mod (used by logtest and the library's own
tests).

Breaking import change for consumers: `logging.NewMockLogger` becomes
`logtest.NewMockLogger`. The backend services that reference it are updated to
the logtest import alongside their go.mod bump to this release.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 18:34:11 +02:00

26 lines
624 B
Go

package logging
import (
"context"
"log/slog"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSetupLogger(t *testing.T) {
for _, format := range []string{"text", "json"} {
l := SetupLogger("info", format, "test-service", "v0.0.0")
assert.NotNil(t, l)
assert.Same(t, l, slog.Default())
}
}
func TestContextLogger(t *testing.T) {
base := SetupLogger("info", "text", "svc", "v1")
assert.Same(t, base, LoggerFromContext(context.Background()))
custom := slog.New(slog.NewTextHandler(nil, nil))
ctx := ContextWithLogger(context.Background(), custom)
assert.Same(t, custom, LoggerFromContext(ctx))
}