mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-03 08:23:04 +00:00
simplify testing
This commit is contained in:
1 parent
3582b9d869
commit
fc63f0432c
99 files changed
+726
-817
No files matched your search
@@ -5,12 +5,11 @@ import (
|
||||
|
||||
"github.com/v2ray/v2ray-core/common"
|
||||
"github.com/v2ray/v2ray-core/common/alloc"
|
||||
"github.com/v2ray/v2ray-core/common/serial"
|
||||
)
|
||||
|
||||
type LogEntry interface {
|
||||
common.Releasable
|
||||
serial.String
|
||||
fmt.Stringer
|
||||
}
|
||||
|
||||
type ErrorLog struct {
|
||||
@@ -37,7 +36,7 @@ func (this *ErrorLog) String() string {
|
||||
b.AppendString(typedVal)
|
||||
case *string:
|
||||
b.AppendString(*typedVal)
|
||||
case serial.String:
|
||||
case fmt.Stringer:
|
||||
b.AppendString(typedVal.String())
|
||||
case error:
|
||||
b.AppendString(typedVal.Error())
|
||||
@@ -49,10 +48,10 @@ func (this *ErrorLog) String() string {
|
||||
}
|
||||
|
||||
type AccessLog struct {
|
||||
From serial.String
|
||||
To serial.String
|
||||
From fmt.Stringer
|
||||
To fmt.Stringer
|
||||
Status string
|
||||
Reason serial.String
|
||||
Reason fmt.Stringer
|
||||
}
|
||||
|
||||
func (this *AccessLog) Release() {
|
||||
|
||||
@@ -5,12 +5,11 @@ import (
|
||||
|
||||
. "github.com/v2ray/v2ray-core/common/log/internal"
|
||||
"github.com/v2ray/v2ray-core/common/serial"
|
||||
v2testing "github.com/v2ray/v2ray-core/testing"
|
||||
"github.com/v2ray/v2ray-core/testing/assert"
|
||||
)
|
||||
|
||||
func TestAccessLog(t *testing.T) {
|
||||
v2testing.Current(t)
|
||||
assert := assert.On(t)
|
||||
|
||||
entry := &AccessLog{
|
||||
From: serial.StringT("test_from"),
|
||||
@@ -20,8 +19,8 @@ func TestAccessLog(t *testing.T) {
|
||||
}
|
||||
|
||||
entryStr := entry.String()
|
||||
assert.StringLiteral(entryStr).Contains(serial.StringT("test_from"))
|
||||
assert.StringLiteral(entryStr).Contains(serial.StringT("test_to"))
|
||||
assert.StringLiteral(entryStr).Contains(serial.StringT("test_reason"))
|
||||
assert.StringLiteral(entryStr).Contains(serial.StringT("Accepted"))
|
||||
assert.String(entryStr).Contains("test_from")
|
||||
assert.String(entryStr).Contains("test_to")
|
||||
assert.String(entryStr).Contains("test_reason")
|
||||
assert.String(entryStr).Contains("Accepted")
|
||||
}
|
||||
Reference in new issue
Block a user