1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 09:56:18 -05:00
v2fly/config/json/json_test.go
2015-09-20 13:08:05 +02:00

49 lines
1.4 KiB
Go

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.Port()).Positive()
assert.Pointer(config.InboundConfig()).IsNotNil()
assert.Pointer(config.OutboundConfig()).IsNotNil()
assert.String(config.InboundConfig().Protocol()).Equals("socks")
assert.Int(len(config.InboundConfig().Content())).GreaterThan(0)
assert.String(config.OutboundConfig().Protocol()).Equals("vmess")
assert.Int(len(config.OutboundConfig().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.Port()).Positive()
assert.Pointer(config.InboundConfig()).IsNotNil()
assert.Pointer(config.OutboundConfig()).IsNotNil()
assert.String(config.InboundConfig().Protocol()).Equals("vmess")
assert.Int(len(config.InboundConfig().Content())).GreaterThan(0)
assert.String(config.OutboundConfig().Protocol()).Equals("freedom")
assert.Int(len(config.OutboundConfig().Content())).Equals(0)
}