(t *testing.T)
| 450 | } |
| 451 | |
| 452 | func 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 | |
| 467 | func TestUpdateHostsRemoveAll(t *testing.T) { |
| 468 | flags := newUpdateCommand(nil).Flags() |
nothing calls this directly
no test coverage detected
searching dependent graphs…