You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/common/log/log_test.go

34 lines
544 B

package log_test
import (
"testing"
6 years ago
"github.com/google/go-cmp/cmp"
"v2ray.com/core/common/log"
"v2ray.com/core/common/net"
)
type testLogger struct {
value string
}
func (l *testLogger) Handle(msg log.Message) {
l.value = msg.String()
}
func TestLogRecord(t *testing.T) {
var logger testLogger
log.RegisterHandler(&logger)
ip := "8.8.8.8"
log.Record(&log.GeneralMessage{
Severity: log.Severity_Error,
Content: net.ParseAddress(ip),
})
6 years ago
if diff := cmp.Diff("[Error] "+ip, logger.value); diff != "" {
t.Error(diff)
6 years ago
}
}