1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00
go-micro/debug/log/default_test.go

27 lines
661 B
Go
Raw Normal View History

2019-11-27 18:02:16 +02:00
package log
import (
"reflect"
"testing"
)
func TestLogger(t *testing.T) {
// make sure we have the right size of the logger ring buffer
if logger.(*defaultLogger).Size() != DefaultSize {
t.Errorf("expected buffer size: %d, got: %d", DefaultSize, logger.(*defaultLogger).Size())
}
// Log some cruft
Log("foobar")
Logf("foo %s", "bar")
// Check if the logs are stored in the logger ring buffer
expectedEntries := []string{"foobar", "foo bar"}
entries := logger.Read(len(expectedEntries))
for i, entry := range entries {
if !reflect.DeepEqual(entry, expectedEntries[i]) {
t.Errorf("expected %s, got %s", expectedEntries[i], entry)
}
}
}