logger/log_test.go

32 lines
487 B
Go
Raw Normal View History

2024-11-15 12:17:38 +01:00
package logger_test
import (
"sync"
"testing"
"git.schreifuchs.ch/schreifuchs/logger"
"git.schreifuchs.ch/schreifuchs/logger/lvl"
)
func TestNewWith(t *testing.T) {
var wg sync.WaitGroup
expected := "Hello World"
got := ""
wg.Add(1)
l := logger.NewWithStrategy(lvl.Debug, func(c <-chan *logger.Log) {
for m := range c {
got = m.Message
wg.Done()
}
})
l.Debug(expected)
wg.Wait()
if expected != got {
t.Errorf("Expected %s but got %s", expected, got)
}
}