diff options
author | Michael Pereira <pereira.m@gmail.com> | 2016-05-05 17:00:08 -0400 |
---|---|---|
committer | Michael Pereira <pereira.m@gmail.com> | 2016-05-05 21:22:27 -0400 |
commit | 0717a698b941335ed49e31044d44dc874b1bf107 (patch) | |
tree | 44895a0f261364efba6270c4f8cc62bb084edb84 /spec/unit | |
parent | 4634f7769c6d5acc488fd149680d4c3eab63276c (diff) | |
download | chef-0717a698b941335ed49e31044d44dc874b1bf107.tar.gz |
Handle numeric id for the user value in the git resource
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/provider/git_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb index 97f04a5a77..48d710450b 100644 --- a/spec/unit/provider/git_spec.rb +++ b/spec/unit/provider/git_spec.rb @@ -267,6 +267,42 @@ SHAS end end + context "with a user id" do + let(:deploy_user) { 123 } + let(:expected_cmd) { 'git clone "git://github.com/opscode/chef.git" "/my/deploy/dir"' } + let(:default_options) do + { + :user => 123, + :environment => { "HOME" => "/home/deployNinja" }, + :log_tag => "git[web2.0 app]", + } + end + before do + @resource.user deploy_user + allow(Etc).to receive(:getpwuid).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja")) + end + context "with a specific home" do + let (:override_home) do + { "HOME" => "/home/masterNinja" } + end + let(:overrided_options) do + { + :user => 123, + :environment => { "HOME" => "/home/masterNinja" }, + :log_tag => "git[web2.0 app]", + } + end + before do + @resource.environment(override_home) + end + before { @resource.environment(override_home) } + it "clones a repo with amended git options with specific home" do + expect(@provider).to receive(:shell_out!).with(expected_cmd, overrided_options) + @provider.clone + end + end + end + it "runs a clone command with escaped destination" do @resource.user "deployNinja" allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja")) |