7001ca854c
Queuing Changes and Cfg Testing * staarting * staarting * startedpush * note * save * mocking * removederrs * fixtests * cleanuperrs * newenvsetup * preppingtests * queue * mmovetocfgpassunittests * sortoutconfig * passinginteg * deps * fixtests
37 lines
849 B
Go
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"])
|
|
}
|