1
0
mirror of https://github.com/volatiletech/authboss.git synced 2025-01-06 03:54:17 +02:00
authboss/defaults/logger_test.go
2020-07-03 11:24:07 -07:00

24 lines
496 B
Go

package defaults
import (
"bytes"
"regexp"
"testing"
)
func TestLogger(t *testing.T) {
t.Parallel()
b := &bytes.Buffer{}
logger := NewLogger(b)
logger.Info("hello")
logger.Error("world")
rgxTimestamp := `[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z`
rgx := regexp.MustCompile(rgxTimestamp + ` \[INFO\]: hello\n` + rgxTimestamp + ` \[EROR\]: world\n`)
if !rgx.Match(b.Bytes()) {
t.Errorf("output from log file did not match regex:\n%s\n%v", b.String(), b.Bytes())
}
}