All checks were successful
check / check (push) Successful in 1m57s
- Migrate Go module path from git.eeqj.de/sneak/webhooker to sneak.berlin/go/webhooker (go.mod, pkg/config/go.mod, all imports) - Drop .json extension from healthcheck endpoint: /.well-known/healthcheck (routes.go, Dockerfile HEALTHCHECK, README) - Add Rate Limiting section to README Design: global rate limiting must not apply to webhook endpoints; per-webhook configurable limits instead - Add Database Architecture section to README Design: separate SQLite files for main app config vs per-processor data (input logs, processor logs, output queues) Addresses review feedback from sneak on PR #6.
66 lines
1.2 KiB
Go
66 lines
1.2 KiB
Go
package logger
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"go.uber.org/fx/fxtest"
|
|
"sneak.berlin/go/webhooker/internal/globals"
|
|
)
|
|
|
|
func TestNew(t *testing.T) {
|
|
// Set up globals
|
|
globals.Appname = "test-app"
|
|
globals.Version = "1.0.0"
|
|
globals.Buildarch = "test-arch"
|
|
|
|
lc := fxtest.NewLifecycle(t)
|
|
g, err := globals.New(lc)
|
|
if err != nil {
|
|
t.Fatalf("globals.New() error = %v", err)
|
|
}
|
|
|
|
params := LoggerParams{
|
|
Globals: g,
|
|
}
|
|
|
|
logger, err := New(lc, params)
|
|
if err != nil {
|
|
t.Fatalf("New() error = %v", err)
|
|
}
|
|
|
|
if logger.Get() == nil {
|
|
t.Error("Get() returned nil logger")
|
|
}
|
|
|
|
// Test that we can log without panic
|
|
logger.Get().Info("test message", "key", "value")
|
|
}
|
|
|
|
func TestEnableDebugLogging(t *testing.T) {
|
|
// Set up globals
|
|
globals.Appname = "test-app"
|
|
globals.Version = "1.0.0"
|
|
globals.Buildarch = "test-arch"
|
|
|
|
lc := fxtest.NewLifecycle(t)
|
|
g, err := globals.New(lc)
|
|
if err != nil {
|
|
t.Fatalf("globals.New() error = %v", err)
|
|
}
|
|
|
|
params := LoggerParams{
|
|
Globals: g,
|
|
}
|
|
|
|
logger, err := New(lc, params)
|
|
if err != nil {
|
|
t.Fatalf("New() error = %v", err)
|
|
}
|
|
|
|
// Enable debug logging should not panic
|
|
logger.EnableDebugLogging()
|
|
|
|
// Test debug logging
|
|
logger.Get().Debug("debug message", "test", true)
|
|
}
|