Skip to content

Commit

Permalink
Added some test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Kapil Chouhan <kapil.chouhan@msystechnologies.com>
  • Loading branch information
Kapil Chouhan committed Jul 2, 2019
1 parent 40e0b62 commit 9a015fd
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions spec/google_server_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Tester
allow(command).to receive(:locate_config_value).with(:connection_protocol).and_return("ssh")
allow(command).to receive(:locate_config_value).with(:ssh_identity_file).and_return("/path/to/file")
allow(command).to receive(:locate_config_value).with(:connection_port).and_return(22)
allow(command).to receive(:locate_config_value).with(:image_os_type).and_return("windows")
allow(command).to receive(:locate_config_value).with(:auto_migrate)
allow(command).to receive(:locate_config_value).with(:auto_restart)
allow(command).to receive(:locate_config_value).with(:chef_node_name)
Expand Down Expand Up @@ -82,6 +83,16 @@ class Tester
expect { tester.check_for_missing_config_values! }.to raise_error(RuntimeError)
end

it "raises an exception if the image_os_type is missing" do
expect(command).to receive(:locate_config_value).with(:image_os_type).and_return(nil)
expect { command.validate_params! }.to raise_error(RuntimeError)
end

it "raises an exception if the connection_port is missing" do
expect(command).to receive(:locate_config_value).with(:connection_port).and_return(nil)
expect { command.validate_params! }.to raise_error(RuntimeError)
end

it "raises an exception if bootstrap is WinRM but no gcloud user email as supplied" do
expect(command).to receive(:locate_config_value).with(:connection_protocol).and_return("winrm")
expect(command).to receive(:locate_config_value).with(:gce_email).and_return(nil)
Expand Down Expand Up @@ -139,9 +150,9 @@ class Tester
expect(command.config[:bootstrap_ip_address]).to eq("1.2.3.4")
end

it "sets the winrm password if winrm is used" do
it "sets the password if image_os_type is windows" do
allow(command.ui).to receive(:msg)
expect(command).to receive(:locate_config_value).with(:connection_protocol).at_least(:once).and_return("winrm")
expect(command).to receive(:locate_config_value).with(:image_os_type).and_return("windows")
expect(command).to receive(:reset_windows_password).and_return("new_password")
command.before_bootstrap

Expand Down

0 comments on commit 9a015fd

Please sign in to comment.