Files
query-orchestration/internal/serviceconfig/logger/config_test.go
T
Michael McGuinness 7001ca854c Merged in feature/docinitialisation (pull request #41)
Queuing Changes and Cfg Testing

* staarting

* staarting

* startedpush

* note

* save

* mocking

* removederrs

* fixtests

* cleanuperrs

* newenvsetup

* preppingtests

* queue

* mmovetocfgpassunittests

* sortoutconfig

* passinginteg

* deps

* fixtests
2025-02-03 17:30:50 +00:00

37 lines
849 B
Go

package logger
import (
"log/slog"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetLogger(t *testing.T) {
cfg := &LogConfig{}
assert.Nil(t, cfg.GetLogger())
cfg.Logger = slog.Default()
assert.NotNil(t, cfg.GetLogger())
}
func TestPrintConfig(t *testing.T) {
cfg := &LogConfig{}
tl := &TestLogger{T: t}
cfg.Logger = slog.New(tl)
cfg.PrintConfig("")
assert.Len(t, tl.Logs, 1)
assert.Equal(t, "Logger", tl.Logs[0]["key"])
}
func TestPrintConfigRecursive(t *testing.T) {
cfg := &LogConfig{}
tl := &TestLogger{T: t}
cfg.Logger = slog.New(tl)
v := struct{ Example string }{Example: "examplestring"}
cfg.printConfigRecursive(reflect.ValueOf(v), "", "", make(map[reflect.Value]bool))
assert.Len(t, tl.Logs, 1)
assert.Equal(t, "Example", tl.Logs[0]["key"])
assert.Equal(t, "examp...", tl.Logs[0]["value"])
}