github.com/moqsien/xraycore@v1.8.5/app/dns/nameserver_local_test.go (about) 1 package dns_test 2 3 import ( 4 "context" 5 "testing" 6 "time" 7 8 . "github.com/moqsien/xraycore/app/dns" 9 "github.com/moqsien/xraycore/common" 10 "github.com/moqsien/xraycore/common/net" 11 "github.com/moqsien/xraycore/features/dns" 12 ) 13 14 func TestLocalNameServer(t *testing.T) { 15 s := NewLocalNameServer() 16 ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) 17 ips, err := s.QueryIP(ctx, "google.com", net.IP{}, dns.IPOption{ 18 IPv4Enable: true, 19 IPv6Enable: true, 20 FakeEnable: false, 21 }, false) 22 cancel() 23 common.Must(err) 24 if len(ips) == 0 { 25 t.Error("expect some ips, but got 0") 26 } 27 }