1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-16 04:35:24 +00:00
v2fly/app/dns/config_json_test.go

29 lines
640 B
Go
Raw Normal View History

2016-05-16 16:19:55 +00:00
// +build json
package dns_test
import (
"encoding/json"
"testing"
2016-08-20 18:55:45 +00:00
. "v2ray.com/core/app/dns"
v2net "v2ray.com/core/common/net"
"v2ray.com/core/testing/assert"
2016-05-16 16:19:55 +00:00
)
func TestConfigParsing(t *testing.T) {
2016-05-24 19:55:46 +00:00
assert := assert.On(t)
2016-05-16 16:19:55 +00:00
rawJson := `{
"servers": ["8.8.8.8"]
}`
config := new(Config)
err := json.Unmarshal([]byte(rawJson), config)
assert.Error(err).IsNil()
assert.Int(len(config.NameServers)).Equals(1)
2016-05-24 13:29:08 +00:00
assert.Destination(config.NameServers[0]).IsUDP()
assert.Address(config.NameServers[0].Address()).Equals(v2net.IPAddress([]byte{8, 8, 8, 8}))
assert.Port(config.NameServers[0].Port()).Equals(v2net.Port(53))
2016-05-16 16:19:55 +00:00
}