receiver_json_test.go 813 B

1234567891011121314151617181920212223242526272829303132333435
  1. // +build json
  2. package outbound_test
  3. import (
  4. "encoding/json"
  5. "testing"
  6. . "github.com/v2ray/v2ray-core/proxy/vmess/outbound"
  7. v2testing "github.com/v2ray/v2ray-core/testing"
  8. "github.com/v2ray/v2ray-core/testing/assert"
  9. )
  10. func TestConfigTargetParsing(t *testing.T) {
  11. v2testing.Current(t)
  12. rawJson := `{
  13. "address": "127.0.0.1",
  14. "port": 80,
  15. "users": [
  16. {
  17. "id": "e641f5ad-9397-41e3-bf1a-e8740dfed019",
  18. "email": "love@v2ray.com",
  19. "level": 999
  20. }
  21. ]
  22. }`
  23. receiver := new(Receiver)
  24. err := json.Unmarshal([]byte(rawJson), &receiver)
  25. assert.Error(err).IsNil()
  26. assert.String(receiver.Destination).Equals("tcp:127.0.0.1:80")
  27. assert.Int(len(receiver.Accounts)).Equals(1)
  28. assert.String(receiver.Accounts[0].ID).Equals("e641f5ad-9397-41e3-bf1a-e8740dfed019")
  29. }