From 927f6534379c56e444a5dd35875b715d3eb3f4aa Mon Sep 17 00:00:00 2001 From: Bryce Shurts Date: Thu, 5 Oct 2017 10:28:25 -0500 Subject: [PATCH] Adding tests for winrm_info_invalid --- .../communicators/winrm/helper_test.rb | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/unit/plugins/communicators/winrm/helper_test.rb b/test/unit/plugins/communicators/winrm/helper_test.rb index f030f7aa3..316966d49 100644 --- a/test/unit/plugins/communicators/winrm/helper_test.rb +++ b/test/unit/plugins/communicators/winrm/helper_test.rb @@ -148,4 +148,31 @@ describe VagrantPlugins::CommunicatorWinRM::Helper do expect(subject.winrm_port(machine)).to eq(2456) end end + + describe ".winrm_info_invalid?" do + it "returns true if it can't detect a host" do + allow(machine).to receive(:ssh_info).and_return(nil) + expect(subject).to be_winrm_info_invalid(machine.ssh_info) + end + + it "returns true if it detects an empty host ip" do + allow(machine).to receive(:ssh_info).and_return({ host: "" }) + expect(subject).to be_winrm_info_invalid(machine.ssh_info) + end + + it "returns true if it detects an unset host ip" do + allow(machine).to receive(:ssh_info).and_return({ host: nil }) + expect(subject).to be_winrm_info_invalid(machine.ssh_info) + end + + it "returns true if it detects an APIPA" do + machine.stub(ssh_info: { host: "169.254.123.123" }) + expect(subject).to be_winrm_info_invalid(machine.ssh_info) + end + + it "returns false if the IP is valid" do + machine.stub(ssh_info: { host: "192.168.123.123" }) + expect(subject).not_to be_winrm_info_invalid(machine.ssh_info) + end + end end