json_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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.Port()).Positive()
  14. assert.Pointer(config.InboundConfig()).IsNotNil()
  15. assert.Pointer(config.OutboundConfig()).IsNotNil()
  16. assert.String(config.InboundConfig().Protocol()).Equals("socks")
  17. assert.Int(len(config.InboundConfig().Content())).GreaterThan(0)
  18. assert.String(config.OutboundConfig().Protocol()).Equals("vmess")
  19. assert.Int(len(config.OutboundConfig().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.Port()).Positive()
  28. assert.Pointer(config.InboundConfig()).IsNotNil()
  29. assert.Pointer(config.OutboundConfig()).IsNotNil()
  30. assert.String(config.InboundConfig().Protocol()).Equals("vmess")
  31. assert.Int(len(config.InboundConfig().Content())).GreaterThan(0)
  32. assert.String(config.OutboundConfig().Protocol()).Equals("freedom")
  33. assert.Int(len(config.OutboundConfig().Content())).Equals(0)
  34. }