diff options
author | Strech (Sergey Fedorov) <oni.strech@gmail.com> | 2015-12-22 23:02:26 +0100 |
---|---|---|
committer | Strech (Sergey Fedorov) <oni.strech@gmail.com> | 2015-12-22 23:02:26 +0100 |
commit | b8f25cea95317a4b2a622e2799f1aa7ba159bdca (patch) | |
tree | b25b192cfe2c2c37215d65c0eb63bed7b8bccf4b /spec/unit/puppet/provider | |
parent | 268e599839f86f7d5dd4352e73c0f698dc4b0c18 (diff) | |
download | puppet-vcsrepo-b8f25cea95317a4b2a622e2799f1aa7ba159bdca.tar.gz puppet-vcsrepo-b8f25cea95317a4b2a622e2799f1aa7ba159bdca.tar.bz2 |
Add mirror option for git cloning
Example:
vcsrepo { '/path/to/repo':
ensure => mirror,
provider => git,
source => 'git://example.com/repo.git',
}
Diffstat (limited to 'spec/unit/puppet/provider')
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/git_spec.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 87113fa..6a8f58f 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -10,7 +10,7 @@ end remote/origin/foo branches - end + end let(:resource) { Puppet::Type.type(:vcsrepo).new({ :name => 'test', :ensure => :present, @@ -111,6 +111,24 @@ branches end end + context "with an ensure of mirror" do + context "with revision" do + it "should raise an error" do + resource[:ensure] = :mirror + expect { provider.create }.to raise_error Puppet::Error, /cannot set a revision.+bare/i + end + end + context "without revision" do + it "should just execute 'git clone --mirror'" do + resource[:ensure] = :mirror + resource.delete(:revision) + provider.expects(:git).with('clone', '--mirror', resource.value(:source), resource.value(:path)) + provider.expects(:update_remotes) + provider.create + end + end + end + context "when a source is not given" do context "when the path does not exist" do it "should execute 'git init'" do @@ -157,6 +175,14 @@ branches provider.expects(:git).with('init', '--bare') provider.create end + + it "should raise an exeption" do + resource[:ensure] = :mirror + resource.delete(:source) + resource.delete(:revision) + + expect { provider.create }.to raise_error Puppet::Error, /cannot init repository with mirror.+try bare/i + end end context "when the path is a working copy repository" do |