receiver_json_test.go 786 B

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