summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/puppet/provider/vcsrepo/git_spec.rb45
1 files changed, 42 insertions, 3 deletions
diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb
index 15fee53..96c4f19 100644
--- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb
@@ -31,6 +31,33 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do
end
end
+ context "with a remote not named 'origin'" do
+ it "should execute 'git clone --origin not_origin" do
+ resource[:remote] = 'not_origin'
+ Dir.expects(:chdir).with('/').at_least_once.yields
+ Dir.expects(:chdir).with('/tmp/test').at_least_once.yields
+ provider.expects(:git).with('clone', '--origin', 'not_origin', resource.value(:source), resource.value(:path))
+ provider.expects(:update_submodules)
+ provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
+ provider.expects(:git).with('checkout', '--force', resource.value(:revision))
+ provider.create
+ end
+ end
+
+ context "with shallow clone enable" do
+ it "should execute 'git clone --depth 1'" do
+ resource[:revision] = 'only/remote'
+ resource[:depth] = 1
+ Dir.expects(:chdir).with('/').at_least_once.yields
+ Dir.expects(:chdir).with('/tmp/test').at_least_once.yields
+ provider.expects(:git).with('clone', '--depth', '1', resource.value(:source), resource.value(:path))
+ provider.expects(:update_submodules)
+ provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
+ provider.expects(:git).with('checkout', '--force', resource.value(:revision))
+ provider.create
+ end
+ end
+
context "with a revision that is not a remote branch" do
it "should execute 'git clone' and 'git reset --hard'" do
resource[:revision] = 'a-commit-or-tag'
@@ -296,6 +323,18 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do
end
end
+ context "retrieving the current revision" do
+ before do
+ expects_chdir
+ provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns("foo\n")
+ end
+
+ it "will strip trailing newlines" do
+ provider.expects(:get_revision).with('origin/foo')
+ provider.latest
+ end
+ end
+
describe 'latest?' do
before do
expects_chdir('/tmp/test')
@@ -323,19 +362,19 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do
end
context 'on master' do
it do
- provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
+ provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns(fixture(:git_branch_a))
provider.latest.should == 'master'
end
end
context 'no branch' do
it do
- provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_none))
+ provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns(fixture(:git_branch_none))
provider.latest.should == 'master'
end
end
context 'feature/bar' do
it do
- provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_feature_bar))
+ provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns(fixture(:git_branch_feature_bar))
provider.latest.should == 'master'
end
end