traefik/pkg/logs/aws_test.go

25 lines
536 B
Go
Raw Permalink Normal View History

2022-11-21 17:36:05 +00:00
package logs
import (
2022-11-23 11:14:04 +00:00
"bytes"
2022-11-21 17:36:05 +00:00
"os"
"testing"
"time"
"github.com/rs/zerolog"
2022-11-23 11:14:04 +00:00
"github.com/stretchr/testify/assert"
2022-11-21 17:36:05 +00:00
)
func TestNewAWSWrapper(t *testing.T) {
2022-11-23 11:14:04 +00:00
buf := bytes.NewBuffer(nil)
cwb := zerolog.ConsoleWriter{Out: buf, TimeFormat: time.RFC3339, NoColor: true}
out := zerolog.MultiLevelWriter(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339}, cwb)
2022-11-21 17:36:05 +00:00
logger := NewAWSWrapper(zerolog.New(out).With().Caller().Logger())
logger.Log("foo")
2022-11-23 11:14:04 +00:00
assert.Equal(t, "<nil> DBG aws_test.go:21 > foo\n", buf.String())
2022-11-21 17:36:05 +00:00
}