@@ -18,10 +18,6 @@ func init() {
18
18
}
19
19
20
20
func TestHostsFileWriteRemoveExistingIp (t * testing.T ) {
21
- getIpv4Address := func () (string , error ) {
22
- return "10.0.0.1" , nil
23
- }
24
-
25
21
readFile = func (filename string ) ([]byte , error ) {
26
22
hostsFile := `
27
23
127.0.0.1 localhost
@@ -43,7 +39,7 @@ func TestHostsFileWriteRemoveExistingIp(t *testing.T) {
43
39
writeFile = emptyWriteFile
44
40
}()
45
41
46
- updateHostsFile ("hostname-1" , ".example.com" , "hosts" , getIpv4Address )
42
+ updateHostsFile ("hostname-1" , ".example.com" , "hosts" , "10.0.0.1" )
47
43
48
44
expected := `
49
45
127.0.0.1 localhost
@@ -57,10 +53,6 @@ func TestHostsFileWriteRemoveExistingIp(t *testing.T) {
57
53
}
58
54
59
55
func TestHostsFileWriteRemoveExistingIpNotLastLine (t * testing.T ) {
60
- getIpv4Address := func () (string , error ) {
61
- return "10.0.0.1" , nil
62
- }
63
-
64
56
readFile = func (filename string ) ([]byte , error ) {
65
57
hostsFile := `
66
58
127.0.0.1 localhost
@@ -83,7 +75,7 @@ func TestHostsFileWriteRemoveExistingIpNotLastLine(t *testing.T) {
83
75
writeFile = emptyWriteFile
84
76
}()
85
77
86
- updateHostsFile ("hostname-1" , ".example.com" , "hosts" , getIpv4Address )
78
+ updateHostsFile ("hostname-1" , ".example.com" , "hosts" , "10.0.0.1" )
87
79
88
80
expected := `
89
81
127.0.0.1 localhost
@@ -98,10 +90,6 @@ func TestHostsFileWriteRemoveExistingIpNotLastLine(t *testing.T) {
98
90
}
99
91
100
92
func TestHostsFileWriteRemoveExistingIpMiddleLastLine (t * testing.T ) {
101
- getIpv4Address := func () (string , error ) {
102
- return "10.0.0.1" , nil
103
- }
104
-
105
93
readFile = func (filename string ) ([]byte , error ) {
106
94
hostsFile := `
107
95
127.0.0.1 localhost
@@ -125,7 +113,7 @@ func TestHostsFileWriteRemoveExistingIpMiddleLastLine(t *testing.T) {
125
113
writeFile = emptyWriteFile
126
114
}()
127
115
128
- updateHostsFile ("hostname-1" , ".example.com" , "hosts" , getIpv4Address )
116
+ updateHostsFile ("hostname-1" , ".example.com" , "hosts" , "10.0.0.1" )
129
117
130
118
expected := `
131
119
127.0.0.1 localhost
@@ -141,10 +129,6 @@ func TestHostsFileWriteRemoveExistingIpMiddleLastLine(t *testing.T) {
141
129
}
142
130
143
131
func TestHostsFileWriteIpNotPresent (t * testing.T ) {
144
- getIpv4Address := func () (string , error ) {
145
- return "10.0.0.1" , nil
146
- }
147
-
148
132
readFile = func (filename string ) ([]byte , error ) {
149
133
hostsFile := `
150
134
127.0.0.1 localhost
@@ -167,7 +151,7 @@ func TestHostsFileWriteIpNotPresent(t *testing.T) {
167
151
writeFile = emptyWriteFile
168
152
}()
169
153
170
- updateHostsFile ("hostname-1" , ".example.com" , "hosts" , getIpv4Address )
154
+ updateHostsFile ("hostname-1" , ".example.com" , "hosts" , "10.0.0.1" )
171
155
172
156
expected := `
173
157
127.0.0.1 localhost
@@ -183,10 +167,6 @@ func TestHostsFileWriteIpNotPresent(t *testing.T) {
183
167
}
184
168
185
169
func TestHostsFileWriteExistingWithDefaultDomain (t * testing.T ) {
186
- getIpv4Address := func () (string , error ) {
187
- return "10.0.0.1" , nil
188
- }
189
-
190
170
readFile = func (filename string ) ([]byte , error ) {
191
171
hostsFile := `
192
172
127.0.0.1 localhost
@@ -210,7 +190,7 @@ func TestHostsFileWriteExistingWithDefaultDomain(t *testing.T) {
210
190
writeFile = emptyWriteFile
211
191
}()
212
192
213
- updateHostsFile ("hostname-1" , ".compute.internal" , "hosts" , getIpv4Address )
193
+ updateHostsFile ("hostname-1" , ".compute.internal" , "hosts" , "10.0.0.1" )
214
194
215
195
expected := `
216
196
127.0.0.1 localhost
0 commit comments