github.com/xmplusdev/xmcore@v1.8.11-0.20240412132628-5518b55526af/app/dns/nameserver_local_test.go (about)

     1  package dns_test
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  	"time"
     7  
     8  	. "github.com/xmplusdev/xmcore/app/dns"
     9  	"github.com/xmplusdev/xmcore/common"
    10  	"github.com/xmplusdev/xmcore/common/net"
    11  	"github.com/xmplusdev/xmcore/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  }