1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 18:06:15 -05:00
v2fly/common/log/log_test.go
Darien Raymond 5e25741742
update tests
2018-07-13 14:36:09 +02:00

33 lines
563 B
Go

package log_test
import (
"testing"
"v2ray.com/core/common/compare"
"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),
})
if err := compare.StringEqualWithDetail("[Error] "+ip, logger.value); err != nil {
t.Fatal(err)
}
}