@@ -358,15 +358,19 @@ func TestUpdateHosts(t *testing.T) {
358358 flags := newUpdateCommand (nil ).Flags ()
359359 flags .Set ("host-add" , "example.net:2.2.2.2" )
360360 flags .Set ("host-add" , "ipv6.net:2001:db8:abc8::1" )
361+ // adding the special "host-gateway" target should work
362+ flags .Set ("host-add" , "host.docker.internal:host-gateway" )
361363 // remove with ipv6 should work
362364 flags .Set ("host-rm" , "example.net:2001:db8:abc8::1" )
363365 // just hostname should work as well
364366 flags .Set ("host-rm" , "example.net" )
367+ // removing the special "host-gateway" target should work
368+ flags .Set ("host-rm" , "gateway.docker.internal:host-gateway" )
365369 // bad format error
366370 assert .ErrorContains (t , flags .Set ("host-add" , "$example.com$" ), `bad format for add-host: "$example.com$"` )
367371
368- hosts := []string {"1.2.3.4 example.com" , "4.3.2.1 example.org" , "2001:db8:abc8::1 example.net" }
369- expected := []string {"1.2.3.4 example.com" , "4.3.2.1 example.org" , "2.2.2.2 example.net" , "2001:db8:abc8::1 ipv6.net" }
372+ hosts := []string {"1.2.3.4 example.com" , "4.3.2.1 example.org" , "2001:db8:abc8::1 example.net" , "gateway.docker.internal:host-gateway" }
373+ expected := []string {"1.2.3.4 example.com" , "4.3.2.1 example.org" , "2.2.2.2 example.net" , "2001:db8:abc8::1 ipv6.net" , "host-gateway host.docker.internal" }
370374
371375 err := updateHosts (flags , & hosts )
372376 assert .NilError (t , err )
0 commit comments