mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
802 B
31 lines
802 B
9 years ago
|
// +build json
|
||
|
|
||
|
package dns_test
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"testing"
|
||
|
|
||
|
. "github.com/v2ray/v2ray-core/app/dns"
|
||
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
||
|
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
|
||
|
v2testing "github.com/v2ray/v2ray-core/testing"
|
||
|
"github.com/v2ray/v2ray-core/testing/assert"
|
||
|
)
|
||
|
|
||
|
func TestConfigParsing(t *testing.T) {
|
||
|
v2testing.Current(t)
|
||
|
|
||
|
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)
|
||
|
netassert.Destination(config.NameServers[0]).IsUDP()
|
||
|
netassert.Address(config.NameServers[0].Address()).Equals(v2net.IPAddress([]byte{8, 8, 8, 8}))
|
||
|
netassert.Port(config.NameServers[0].Port()).Equals(v2net.Port(53))
|
||
|
}
|