spec/functional/bootstrap_download_spec.rb in knife-windows-0.5.12 vs spec/functional/bootstrap_download_spec.rb in knife-windows-0.5.14.rc.0
- old
+ new
@@ -48,10 +48,13 @@
@temp_directory = Dir.mktmpdir("bootstrap_test")
# Location to which the download script will be modified to write
# the downloaded msi
@local_file_download_destination = "#{@temp_directory}/chef-client-latest.msi"
+
+ source_code_directory = File.dirname(__FILE__)
+ @template_file_path ="#{source_code_directory}/../../lib/chef/knife/bootstrap/windows-chef-client-msi.erb"
end
after(:all) do
# Clear the temp directory upon exit
if Dir.exists?(@temp_directory)
@@ -62,19 +65,20 @@
describe "running on any version of the Windows OS", :windows_only do
before do
@mock_bootstrap_context = Chef::Knife::Core::WindowsBootstrapContext.new({ }, nil, { })
# Stub the bootstrap context and prevent config related sections
- # to be populated, chef installation and first chef run
+ # from being populated, i.e. chef installation and first chef
+ # run sections
@mock_bootstrap_context.stub(:validation_key).and_return("echo.validation_key")
@mock_bootstrap_context.stub(:encrypted_data_bag_secret).and_return("echo.encrypted_data_bag_secret")
@mock_bootstrap_context.stub(:config_content).and_return("echo.config_content")
@mock_bootstrap_context.stub(:start_chef).and_return("echo.echo start_chef_command")
@mock_bootstrap_context.stub(:run_list).and_return("echo.run_list")
@mock_bootstrap_context.stub(:install_chef).and_return("echo.echo install_chef_command")
- # Change the directorires where bootstrap files will be created
+ # Change the directories where bootstrap files will be created
@mock_bootstrap_context.stub(:bootstrap_directory).and_return(@temp_directory.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR))
@mock_bootstrap_context.stub(:local_download_path).and_return(@local_file_download_destination.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR))
# Prevent password prompt during bootstrap process
@mock_winrm = Chef::Knife::Winrm.new
@@ -85,28 +89,29 @@
end
it "downloads the chef-client MSI during winrm bootstrap" do
clean_test_case
- bootstrap_context = Chef::Knife::BootstrapWindowsWinrm.new([ "127.0.0.1" ])
+ winrm_bootstrapper = Chef::Knife::BootstrapWindowsWinrm.new([ "127.0.0.1" ])
+ winrm_bootstrapper.config[:template_file] = @template_file_path
# Execute the commands locally that would normally be executed via WinRM
- bootstrap_context.stub(:run_command) do |command|
+ winrm_bootstrapper.stub(:run_command) do |command|
system(command)
end
- bootstrap_context.run
+ winrm_bootstrapper.run
# Download should succeed
download_succeeded?.should == true
end
end
def download_succeeded?
File.exists?(@local_file_download_destination) && ! File.zero?(@local_file_download_destination)
end
- # Remove file artifiacts generated by individual test cases
+ # Remove file artifacts generated by individual test cases
def clean_test_case
if File.exists?(@local_file_download_destination)
File.delete(@local_file_download_destination)
end
end