forked from hashicorp/vagrant
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CommandBuilderWindows would not include the Chef binary in the command when the binary_path was specified in the config. Backfilled unit tests for CommandBuilderWindows
- Loading branch information
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
test/unit/plugins/provisioners/chef/command_build_windows_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require_relative "../../../base" | ||
|
||
require Vagrant.source_root.join("plugins/provisioners/chef/command_builder_windows") | ||
|
||
describe VagrantPlugins::Chef::CommandBuilderWindows do | ||
|
||
let(:machine) { double("machine") } | ||
let(:chef_config) { double("chef_config") } | ||
|
||
subject do | ||
VagrantPlugins::Chef::CommandBuilderWindows.new(machine, chef_config, :client) | ||
end | ||
|
||
before(:each) do | ||
allow(chef_config).to receive(:provisioning_path).and_return('/tmp/vagrant-chef-1') | ||
allow(chef_config).to receive(:arguments).and_return(nil) | ||
allow(chef_config).to receive(:binary_env).and_return(nil) | ||
allow(chef_config).to receive(:binary_path).and_return(nil) | ||
end | ||
|
||
describe '.initialize' do | ||
it 'should raise when chef type is not client or solo' do | ||
expect { VagrantPlugins::Chef::CommandBuilderWindows.new(machine, chef_config, :client_bad) }. | ||
to raise_error | ||
end | ||
end | ||
|
||
describe '.build_command' do | ||
it "executes the chef-client in PATH by default" do | ||
expect(subject.build_command()).to match(/^chef-client/) | ||
end | ||
|
||
it "executes the chef-client using full path if binary_path is specified" do | ||
allow(chef_config).to receive(:binary_path).and_return( | ||
"c:\\opscode\\chef\\bin\\chef-client") | ||
expect(subject.build_command()).to match(/^c:\\opscode\\chef\\bin\\chef-client\\chef-client/) | ||
end | ||
|
||
it "builds a windows friendly client.rb path" do | ||
expect(subject.build_command()).to include( | ||
'-c c:\\tmp\\vagrant-chef-1\\client.rb') | ||
end | ||
|
||
it "builds a windows friendly solo.json path" do | ||
expect(subject.build_command()).to include( | ||
'-j c:\\tmp\\vagrant-chef-1\\dna.json') | ||
end | ||
|
||
it 'includes Chef arguments if specified' do | ||
allow(chef_config).to receive(:arguments).and_return("-l DEBUG") | ||
expect(subject.build_command()).to include( | ||
'-l DEBUG') | ||
end | ||
end | ||
end |