MCPcopy Create free account
hub / github.com/docker/cli / TestValidateExtraHosts

Function TestValidateExtraHosts

opts/hosts_test.go:150–298  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

148}
149
150func TestValidateExtraHosts(t *testing.T) {
151 tests := []struct {
152 doc string
153 input string
154 expectedOut string // Expect output==input if not set.
155 expectedErr string // Expect success if not set.
156 }{
157 {
158 doc: "IPv4, colon sep",
159 input: `myhost:192.168.0.1`,
160 },
161 {
162 doc: "IPv4, eq sep",
163 input: `myhost=192.168.0.1`,
164 expectedOut: `myhost:192.168.0.1`,
165 },
166 {
167 doc: "Weird but permitted, IPv4 with brackets",
168 input: `myhost=[192.168.0.1]`,
169 expectedOut: `myhost:192.168.0.1`,
170 },
171 {
172 doc: "Host and domain",
173 input: `host.and.domain.invalid:10.0.2.1`,
174 },
175 {
176 doc: "IPv6, colon sep",
177 input: `anipv6host:2003:ab34:e::1`,
178 },
179 {
180 doc: "IPv6, colon sep, brackets",
181 input: `anipv6host:[2003:ab34:e::1]`,
182 expectedOut: `anipv6host:2003:ab34:e::1`,
183 },
184 {
185 doc: "IPv6, eq sep, brackets",
186 input: `anipv6host=[2003:ab34:e::1]`,
187 expectedOut: `anipv6host:2003:ab34:e::1`,
188 },
189 {
190 doc: "IPv6 localhost, colon sep",
191 input: `ipv6local:::1`,
192 },
193 {
194 doc: "IPv6 localhost, eq sep",
195 input: `ipv6local=::1`,
196 expectedOut: `ipv6local:::1`,
197 },
198 {
199 doc: "IPv6 localhost, eq sep, brackets",
200 input: `ipv6local=[::1]`,
201 expectedOut: `ipv6local:::1`,
202 },
203 {
204 doc: "IPv6 localhost, non-canonical, colon sep",
205 input: `ipv6local:0:0:0:0:0:0:0:1`,
206 },
207 {

Callers

nothing calls this directly

Calls 2

ValidateExtraHostFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…