@@ -59,10 +59,10 @@ var lookupStaticHostTests = []struct {
59
59
}
60
60
61
61
func TestLookupStaticHost (t * testing.T ) {
62
- defer func (orig string ) { testHookHostsPath = orig }(testHookHostsPath )
62
+ defer func (orig string ) { hostsFilePath = orig }(hostsFilePath )
63
63
64
64
for _ , tt := range lookupStaticHostTests {
65
- testHookHostsPath = tt .name
65
+ hostsFilePath = tt .name
66
66
for _ , ent := range tt .ents {
67
67
testStaticHost (t , tt .name , ent )
68
68
}
@@ -128,10 +128,10 @@ var lookupStaticAddrTests = []struct {
128
128
}
129
129
130
130
func TestLookupStaticAddr (t * testing.T ) {
131
- defer func (orig string ) { testHookHostsPath = orig }(testHookHostsPath )
131
+ defer func (orig string ) { hostsFilePath = orig }(hostsFilePath )
132
132
133
133
for _ , tt := range lookupStaticAddrTests {
134
- testHookHostsPath = tt .name
134
+ hostsFilePath = tt .name
135
135
for _ , ent := range tt .ents {
136
136
testStaticAddr (t , tt .name , ent )
137
137
}
@@ -151,27 +151,27 @@ func testStaticAddr(t *testing.T, hostsPath string, ent staticHostEntry) {
151
151
func TestHostCacheModification (t * testing.T ) {
152
152
// Ensure that programs can't modify the internals of the host cache.
153
153
// See https://golang.org/issues/14212.
154
- defer func (orig string ) { testHookHostsPath = orig }(testHookHostsPath )
154
+ defer func (orig string ) { hostsFilePath = orig }(hostsFilePath )
155
155
156
- testHookHostsPath = "testdata/ipv4-hosts"
156
+ hostsFilePath = "testdata/ipv4-hosts"
157
157
ent := staticHostEntry {"localhost" , []string {"127.0.0.1" , "127.0.0.2" , "127.0.0.3" }}
158
- testStaticHost (t , testHookHostsPath , ent )
158
+ testStaticHost (t , hostsFilePath , ent )
159
159
// Modify the addresses return by lookupStaticHost.
160
160
addrs , _ := lookupStaticHost (ent .in )
161
161
for i := range addrs {
162
162
addrs [i ] += "junk"
163
163
}
164
- testStaticHost (t , testHookHostsPath , ent )
164
+ testStaticHost (t , hostsFilePath , ent )
165
165
166
- testHookHostsPath = "testdata/ipv6-hosts"
166
+ hostsFilePath = "testdata/ipv6-hosts"
167
167
ent = staticHostEntry {"::1" , []string {"localhost" }}
168
- testStaticAddr (t , testHookHostsPath , ent )
168
+ testStaticAddr (t , hostsFilePath , ent )
169
169
// Modify the hosts return by lookupStaticAddr.
170
170
hosts := lookupStaticAddr (ent .in )
171
171
for i := range hosts {
172
172
hosts [i ] += "junk"
173
173
}
174
- testStaticAddr (t , testHookHostsPath , ent )
174
+ testStaticAddr (t , hostsFilePath , ent )
175
175
}
176
176
177
177
var lookupStaticHostAliasesTest = []struct {
@@ -195,9 +195,9 @@ var lookupStaticHostAliasesTest = []struct {
195
195
}
196
196
197
197
func TestLookupStaticHostAliases (t * testing.T ) {
198
- defer func (orig string ) { testHookHostsPath = orig }(testHookHostsPath )
198
+ defer func (orig string ) { hostsFilePath = orig }(hostsFilePath )
199
199
200
- testHookHostsPath = "testdata/aliases"
200
+ hostsFilePath = "testdata/aliases"
201
201
for _ , ent := range lookupStaticHostAliasesTest {
202
202
testLookupStaticHostAliases (t , ent .lookup , absDomainName (ent .res ))
203
203
}
0 commit comments