json_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package json
  2. import (
  3. "path/filepath"
  4. "testing"
  5. "github.com/v2ray/v2ray-core/testing/unit"
  6. )
  7. func TestClientSampleConfig(t *testing.T) {
  8. assert := unit.Assert(t)
  9. // TODO: fix for Windows
  10. baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
  11. config, err := LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
  12. assert.Error(err).IsNil()
  13. assert.Uint16(config.PortValue).Positive()
  14. assert.Pointer(config.InboundConfigValue).IsNotNil()
  15. assert.Pointer(config.OutboundConfigValue).IsNotNil()
  16. assert.String(config.InboundConfigValue.ProtocolString).Equals("socks")
  17. assert.Int(len(config.InboundConfigValue.Content())).GreaterThan(0)
  18. assert.String(config.OutboundConfigValue.ProtocolString).Equals("vmess")
  19. assert.Int(len(config.OutboundConfigValue.Content())).GreaterThan(0)
  20. }
  21. func TestServerSampleConfig(t *testing.T) {
  22. assert := unit.Assert(t)
  23. // TODO: fix for Windows
  24. baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
  25. config, err := LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json"))
  26. assert.Error(err).IsNil()
  27. assert.Uint16(config.PortValue).Positive()
  28. assert.Pointer(config.InboundConfigValue).IsNotNil()
  29. assert.Pointer(config.OutboundConfigValue).IsNotNil()
  30. assert.String(config.InboundConfigValue.ProtocolString).Equals("vmess")
  31. assert.Int(len(config.InboundConfigValue.Content())).GreaterThan(0)
  32. assert.String(config.OutboundConfigValue.ProtocolString).Equals("freedom")
  33. }