mirror of https://github.com/v2ray/v2ray-core
parent
a887fd01b8
commit
07d4495b27
@ -0,0 +1,47 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/v2ray/v2ray-core/testing/unit"
|
||||
)
|
||||
|
||||
func TestClientSampleConfig(t *testing.T) {
|
||||
assert := unit.Assert(t)
|
||||
|
||||
// TODO: fix for Windows
|
||||
baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
|
||||
|
||||
config, err := LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
assert.Uint16(config.PortValue).Positive()
|
||||
assert.Pointer(config.InboundConfigValue).IsNotNil()
|
||||
assert.Pointer(config.OutboundConfigValue).IsNotNil()
|
||||
|
||||
assert.String(config.InboundConfigValue.ProtocolString).Equals("socks")
|
||||
assert.Int(len(config.InboundConfigValue.Content())).GreaterThan(0)
|
||||
|
||||
assert.String(config.OutboundConfigValue.ProtocolString).Equals("vmess")
|
||||
assert.Int(len(config.OutboundConfigValue.Content())).GreaterThan(0)
|
||||
}
|
||||
|
||||
func TestServerSampleConfig(t *testing.T) {
|
||||
assert := unit.Assert(t)
|
||||
|
||||
// TODO: fix for Windows
|
||||
baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
|
||||
|
||||
config, err := LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json"))
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
assert.Uint16(config.PortValue).Positive()
|
||||
assert.Pointer(config.InboundConfigValue).IsNotNil()
|
||||
assert.Pointer(config.OutboundConfigValue).IsNotNil()
|
||||
|
||||
assert.String(config.InboundConfigValue.ProtocolString).Equals("vmess")
|
||||
assert.Int(len(config.InboundConfigValue.Content())).GreaterThan(0)
|
||||
|
||||
assert.String(config.OutboundConfigValue.ProtocolString).Equals("freedom")
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type PointerSubject struct {
|
||||
*Subject
|
||||
value interface{}
|
||||
}
|
||||
|
||||
func NewPointerSubject(base *Subject, value interface{}) *PointerSubject {
|
||||
return &PointerSubject{
|
||||
Subject: base,
|
||||
value: value,
|
||||
}
|
||||
}
|
||||
|
||||
func (subject *PointerSubject) Named(name string) *PointerSubject {
|
||||
subject.Subject.Named(name)
|
||||
return subject
|
||||
}
|
||||
|
||||
func (subject *PointerSubject) Fail(verb string, other interface{}) {
|
||||
subject.FailWithMessage(fmt.Sprintf("Not true that %s %s <%v>.", subject.DisplayString(), verb, other))
|
||||
}
|
||||
|
||||
func (subject *PointerSubject) DisplayString() string {
|
||||
return subject.Subject.DisplayString(fmt.Sprintf("%v", subject.value))
|
||||
}
|
||||
|
||||
func (subject *PointerSubject) Equals(expectation interface{}) {
|
||||
if subject.value != expectation {
|
||||
subject.Fail("is equal to", expectation)
|
||||
}
|
||||
}
|
||||
|
||||
func (subject *PointerSubject) IsNil() {
|
||||
if subject.value != nil {
|
||||
subject.FailWithMessage("Not true that " + subject.DisplayString() + " is nil.")
|
||||
}
|
||||
}
|
||||
|
||||
func (subject *PointerSubject) IsNotNil() {
|
||||
if subject.value == nil {
|
||||
subject.FailWithMessage("Not true that " + subject.DisplayString() + " is not nil.")
|
||||
}
|
||||
}
|
Loading…
Reference in new issue