@@ -10,7 +10,6 @@ import (
10
10
"context"
11
11
"errors"
12
12
"fmt"
13
- "internal/testenv"
14
13
"os"
15
14
"path"
16
15
"path/filepath"
@@ -2200,9 +2199,6 @@ var goLookupIPCNAMEOrderDNSFilesModeTests = []struct {
2200
2199
}
2201
2200
2202
2201
func TestGoLookupIPCNAMEOrderHostsAliasesDNSFilesMode (t * testing.T ) {
2203
- if testenv .Builder () == "" {
2204
- t .Skip ("Makes assumptions about local networks and (re)naming that aren't always true" )
2205
- }
2206
2202
defer func (orig string ) { testHookHostsPath = orig }(testHookHostsPath )
2207
2203
testHookHostsPath = "testdata/aliases"
2208
2204
mode := hostLookupDNSFiles
@@ -2213,9 +2209,29 @@ func TestGoLookupIPCNAMEOrderHostsAliasesDNSFilesMode(t *testing.T) {
2213
2209
}
2214
2210
2215
2211
func testGoLookupIPCNAMEOrderHostsAliases (t * testing.T , mode hostLookupOrder , lookup , lookupRes string ) {
2212
+ fake := fakeDNSServer {
2213
+ rh : func (_ , _ string , q dnsmessage.Message , _ time.Time ) (dnsmessage.Message , error ) {
2214
+ var answers []dnsmessage.Resource
2215
+
2216
+ if mode != hostLookupDNSFiles {
2217
+ t .Fatal ("received unexpected DNS query" )
2218
+ }
2219
+
2220
+ return dnsmessage.Message {
2221
+ Header : dnsmessage.Header {
2222
+ ID : q .Header .ID ,
2223
+ Response : true ,
2224
+ },
2225
+ Questions : []dnsmessage.Question {q .Questions [0 ]},
2226
+ Answers : answers ,
2227
+ }, nil
2228
+ },
2229
+ }
2230
+
2231
+ r := Resolver {PreferGo : true , Dial : fake .DialContext }
2216
2232
ins := []string {lookup , absDomainName (lookup ), strings .ToLower (lookup ), strings .ToUpper (lookup )}
2217
2233
for _ , in := range ins {
2218
- _ , res , err := goResolver .goLookupIPCNAMEOrder (context .Background (), "ip" , in , mode , nil )
2234
+ _ , res , err := r .goLookupIPCNAMEOrder (context .Background (), "ip" , in , mode , nil )
2219
2235
if err != nil {
2220
2236
t .Errorf ("expected err == nil, but got error: %v" , err )
2221
2237
}
0 commit comments