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

Function TestUpdateHostsRemoveHostIP

cli/command/service/update_test.go:452–465  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

450}
451
452func TestUpdateHostsRemoveHostIP(t *testing.T) {
453 flags := newUpdateCommand(nil).Flags()
454 flags.Set("host-rm", "host1:127.0.0.1")
455
456 hosts := []string{"127.0.0.2 host3 host1 host2 host4", "127.0.0.1 host1 host4", "127.0.0.3 host1", "127.0.0.1 host1"}
457
458 err := updateHosts(flags, &hosts)
459 assert.NilError(t, err)
460
461 // Removing host `host1` should remove the entry from each line it appears in,
462 // but only if the IP-address matches. If there are no other hosts in the entry,
463 // the entry itself should be removed.
464 assert.Check(t, is.DeepEqual([]string{"127.0.0.2 host3 host1 host2 host4", "127.0.0.1 host4", "127.0.0.3 host1"}, hosts))
465}
466
467func TestUpdateHostsRemoveAll(t *testing.T) {
468 flags := newUpdateCommand(nil).Flags()

Callers

nothing calls this directly

Calls 3

updateHostsFunction · 0.85
newUpdateCommandFunction · 0.70
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…