Added rspec tests for async server deletion

This commit is contained in:
siddheshwar-more 2013-11-25 21:16:10 +05:30 коммит произвёл adamedx
Родитель 8cc21a6957
Коммит 7ae0cefaf5
1 изменённых файлов: 24 добавлений и 1 удалений

Просмотреть файл

@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require File.expand_path(File.dirname(__FILE__) + '/../unit/query_azure_mock')
require 'mixlib/shellout'
describe Chef::Knife::AzureServerDelete do
include AzureSpecHelper
include QueryAzureMock
@ -30,6 +30,7 @@ before do
@server_instance.stub(:print)
@server_instance.ui.stub(:warn)
@server_instance.ui.should_not_receive(:error).and_call_original
Chef::Config[:knife][:wait] = true
end
it "server delete test" do
@ -209,6 +210,28 @@ end
lambda { @server_instance.validate_disk_and_storage }.should raise_error(SystemExit)
end
context "asynchronous server delete" do
before(:each) do
Chef::Config[:knife][:wait]=false
Dir.stub(:mktmpdir)
@server_instance.ui.should_receive(:info).twice
@server_instance.stub(:exit!)
@shell_out = Object.new
@shell_out.class.class_eval{attr_accessor :timeout}
@shell_out.define_singleton_method(:run_command){}
Mixlib::ShellOut.stub(:new).and_return(@shell_out)
end
it "successfull delete server" do
@server_instance.name_args = ['role001']
@server_instance.ui.should_receive(:warn).twice
@server_instance.connection.roles.should_receive(:delete).and_call_original
@shell_out.should_receive(:run_command)
@server_instance.run
@shell_out.timeout.should == 3000
end
end
after(:each) do
Chef::Config[:knife][:preserve_azure_os_disk] = false if Chef::Config[:knife][:preserve_azure_os_disk] #cleanup config for each run
Chef::Config[:knife][:delete_azure_storage_account] = false if Chef::Config[:knife][:delete_azure_storage_account]