diff options
author | Serdar Sutay <serdar@opscode.com> | 2014-10-10 15:28:28 -0700 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2014-10-10 15:28:28 -0700 |
commit | 685042c1ea839cef2ad7fe440df1fc0955535581 (patch) | |
tree | edb81ca9f83619055d3ebd56cfb00fa0afcee003 /spec/unit/provider | |
parent | 0b44df383395482d96e317babf0546068c30b7ec (diff) | |
parent | eb9b7d065feb003192fcf9295e9a3fc4f8ffe8f3 (diff) | |
download | chef-685042c1ea839cef2ad7fe440df1fc0955535581.tar.gz |
Merge pull request #2079 from jbence/CHEF-2065
Use exact match to locate remote git-reference
Diffstat (limited to 'spec/unit/provider')
-rw-r--r-- | spec/unit/provider/git_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb index ff1c0b0398..02d155efbd 100644 --- a/spec/unit/provider/git_spec.rb +++ b/spec/unit/provider/git_spec.rb @@ -106,6 +106,52 @@ describe Chef::Provider::Git do @provider.target_revision.should eql("663c22a5e41f5ae3193460cca044ed1435029f53") end + it "converts resource.revision from a tag to a SHA using an exact match" do + @resource.revision "v1.0" + @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/releases/v1.0\n" + + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n") + @provider.should_receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) + @provider.target_revision.should eql("503c22a5e41f5ae3193460cca044ed1435029f53") + end + + it "converts resource.revision from a tag to a SHA, matching tags first, then heads" do + @resource.revision "v1.0" + @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" + + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") + @provider.should_receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) + @provider.target_revision.should eql("663c22a5e41f5ae3193460cca044ed1435029f53") + end + + it "converts resource.revision from a tag to a SHA, matching heads if no tags match" do + @resource.revision "v1.0" + @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.1\n" + + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") + @provider.should_receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) + @provider.target_revision.should eql("503c22a5e41f5ae3193460cca044ed1435029f53") + end + + it "converts resource.revision from a tag to a SHA, matching tags first, then heads, then revision" do + @resource.revision "refs/pulls/v1.0" + @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" + + "805c22a5e41f5ae3193460cca044ed1435029f53\trefs/pulls/v1.0\n" + + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") + @provider.should_receive(:shell_out!).with(@git_ls_remote + "\"refs/pulls/v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) + @provider.target_revision.should eql("805c22a5e41f5ae3193460cca044ed1435029f53") + end + + it "converts resource.revision from a tag to a SHA, using full path if provided" do + @resource.revision "refs/heads/v1.0" + @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" + + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") + @provider.should_receive(:shell_out!).with(@git_ls_remote + "\"refs/heads/v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) + @provider.target_revision.should eql("503c22a5e41f5ae3193460cca044ed1435029f53") + end + it "raises an invalid remote reference error if you try to deploy from ``origin'' and assertions are run" do @resource.revision "origin/" @provider.action = :checkout |