add specs around network restart logic
This commit is contained in:
parent
86ab4533b1
commit
a12b09b098
|
@ -39,5 +39,32 @@ describe "VagrantPlugins::GuestRedHat::Cap::ChangeHostName" do
|
|||
cap.change_host_name(machine, name)
|
||||
expect(comm.received_commands.size).to eq(1)
|
||||
end
|
||||
|
||||
context "restarts the network" do
|
||||
it "uses systemctl and NetworkManager.service" do
|
||||
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||
comm.stub_command("test -f /usr/bin/systemctl && systemctl -q is-active NetworkManager.service", exit_code: 0)
|
||||
cap.change_host_name(machine, name)
|
||||
expect(comm.received_commands[1]).to match(/systemctl restart NetworkManager.service/)
|
||||
end
|
||||
|
||||
it "uses the service command" do
|
||||
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||
comm.stub_command("test -f /usr/bin/systemctl && systemctl -q is-active NetworkManager.service", exit_code: 1)
|
||||
comm.stub_command("test -f /etc/init.d/network", exit_code: 0)
|
||||
cap.change_host_name(machine, name)
|
||||
expect(comm.received_commands[1]).to match(/service network restart/)
|
||||
end
|
||||
end
|
||||
|
||||
context "cannot restart the network" do
|
||||
it "prints cannot restart message" do
|
||||
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||
comm.stub_command("test -f /usr/bin/systemctl && systemctl -q is-active NetworkManager.service", exit_code: 1)
|
||||
comm.stub_command("test -f /etc/init.d/network", exit_code: 1)
|
||||
cap.change_host_name(machine, name)
|
||||
expect(comm.received_commands[1]).to match(/printf "Could not restart the network to set the new hostname!/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue