55	"sort" 
66	"sync" 
77	"testing" 
8+ 	"time" 
89
910	"github.com/miekg/dns" 
1011	"github.com/stretchr/testify/assert" 
@@ -195,6 +196,7 @@ var findXByFqdnTestCases = []struct {
195196	primaryNs      string 
196197	nameservers    []string 
197198	expectedError  string  // regular expression 
199+ 	timeout        time.Duration 
198200}{
199201	{
200202		desc :        "domain is a CNAME" ,
@@ -237,6 +239,7 @@ var findXByFqdnTestCases = []struct {
237239		zone :        "google.com." ,
238240		primaryNs :   "ns1.google.com." ,
239241		nameservers : []string {":7053" , ":8053" , "8.8.8.8:53" },
242+ 		timeout :     500  *  time .Millisecond ,
240243	},
241244	{
242245		desc :        "only non-existent nameservers" ,
@@ -246,7 +249,8 @@ var findXByFqdnTestCases = []struct {
246249		// NOTE: On Windows, net.DialContext finds a way down to the ContectEx syscall. 
247250		// There a fault is marked as "connectex", not "connect", see 
248251		// https://cs.opensource.google/go/go/+/refs/tags/go1.19.5:src/net/fd_windows.go;l=112 
249- 		expectedError : `^could not find the start of authority for mail\.google\.com.: dial tcp :9053: connect(ex)?:` ,
252+ 		expectedError : `^could not find the start of authority for mail\.google\.com.: dial tcp :9053:.+` ,
253+ 		timeout :       500  *  time .Millisecond ,
250254	},
251255	{
252256		desc :          "no nameservers" ,
@@ -277,6 +281,11 @@ func TestFindZoneByFqdnCustom(t *testing.T) {
277281func  TestFindPrimaryNsByFqdnCustom (t  * testing.T ) {
278282	for  _ , test  :=  range  findXByFqdnTestCases  {
279283		t .Run (test .desc , func (t  * testing.T ) {
284+ 			origTimeout  :=  dnsTimeout 
285+ 			if  test .timeout  >  0  {
286+ 				dnsTimeout  =  test .timeout 
287+ 			}
288+ 
280289			ClearFqdnCache ()
281290
282291			ns , err  :=  FindPrimaryNsByFqdnCustom (test .fqdn , test .nameservers )
@@ -287,6 +296,8 @@ func TestFindPrimaryNsByFqdnCustom(t *testing.T) {
287296				require .NoError (t , err )
288297				assert .Equal (t , test .primaryNs , ns )
289298			}
299+ 
300+ 			dnsTimeout  =  origTimeout 
290301		})
291302	}
292303}
0 commit comments