summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/provider/vcsrepo/svn_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/puppet/provider/vcsrepo/svn_spec.rb')
-rw-r--r--spec/unit/puppet/provider/vcsrepo/svn_spec.rb132
1 files changed, 99 insertions, 33 deletions
diff --git a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb
index 5c03327..6a37c20 100644
--- a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb
@@ -1,41 +1,85 @@
require 'spec_helper'
-describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do
+describe Puppet::Type.type(:vcsrepo).provider(:svn) do
+
+ let(:resource) { Puppet::Type.type(:vcsrepo).new({
+ :name => 'test',
+ :ensure => :present,
+ :provider => :svn,
+ :path => '/tmp/vcsrepo',
+ })}
+
+ let(:provider) { resource.provider }
+
+ before :each do
+ Puppet::Util.stubs(:which).with('git').returns('/usr/bin/git')
+ end
describe 'creating' do
- resource_with :source do
- resource_with :revision do
- it "should execute 'svn checkout' with a revision" do
- provider.expects(:svn).with('--non-interactive', 'checkout', '-r',
- resource.value(:revision),
- resource.value(:source),
- resource.value(:path))
- provider.create
- end
+ context 'with source and revision' do
+ it "should execute 'svn checkout' with a revision" do
+ resource[:source] = 'exists'
+ resource[:revision] = '1'
+ provider.expects(:svn).with('--non-interactive', 'checkout', '-r',
+ resource.value(:revision),
+ resource.value(:source),
+ resource.value(:path))
+ provider.create
+ end
+ end
+ context 'with source' do
+ it "should just execute 'svn checkout' without a revision" do
+ resource[:source] = 'exists'
+ provider.expects(:svn).with('--non-interactive', 'checkout',
+ resource.value(:source),
+ resource.value(:path))
+ provider.create
+ end
+ end
+
+ context 'with fstype' do
+ it "should execute 'svnadmin create' with an '--fs-type' option" do
+ resource[:fstype] = 'ext4'
+ provider.expects(:svnadmin).with('create', '--fs-type',
+ resource.value(:fstype),
+ resource.value(:path))
+ provider.create
+ end
+ end
+ context 'without fstype' do
+ it "should execute 'svnadmin create' without an '--fs-type' option" do
+ provider.expects(:svnadmin).with('create', resource.value(:path))
+ provider.create
end
- resource_without :revision do
- it "should just execute 'svn checkout' without a revision" do
- provider.expects(:svn).with('--non-interactive', 'checkout',
- resource.value(:source),
- resource.value(:path))
- provider.create
- end
+ end
+
+ context "with depth" do
+ it "should execute 'svn checkout' with a depth" do
+ resource[:source] = 'exists'
+ resource[:depth] = 'infinity'
+ provider.expects(:svn).with('--non-interactive', 'checkout', '--depth', 'infinity',
+ resource.value(:source),
+ resource.value(:path))
+ provider.create
end
end
- resource_without :source do
- resource_with :fstype do
- it "should execute 'svnadmin create' with an '--fs-type' option" do
- provider.expects(:svnadmin).with('create', '--fs-type',
- resource.value(:fstype),
- resource.value(:path))
- provider.create
- end
+
+ context "with trust_server_cert" do
+ it "should execute 'svn checkout' without a trust-server-cert" do
+ resource[:source] = 'exists'
+ resource[:trust_server_cert] = :false
+ provider.expects(:svn).with('--non-interactive', 'checkout',
+ resource.value(:source),
+ resource.value(:path))
+ provider.create
end
- resource_without :fstype do
- it "should execute 'svnadmin create' without an '--fs-type' option" do
- provider.expects(:svnadmin).with('create', resource.value(:path))
- provider.create
- end
+ it "should execute 'svn checkout' with a trust-server-cert" do
+ resource[:source] = 'exists'
+ resource[:trust_server_cert] = :true
+ provider.expects(:svn).with('--non-interactive', '--trust-server-cert', 'checkout',
+ resource.value(:source),
+ resource.value(:path))
+ provider.create
end
end
end
@@ -61,7 +105,7 @@ describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do
end
it "should use 'svn info'" do
expects_chdir
- provider.revision.should == '4' # From 'Revision', not 'Last Changed Rev'
+ expect(provider.revision).to eq('4') # From 'Revision', not 'Last Changed Rev'
end
end
@@ -69,7 +113,17 @@ describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do
before do
@revision = '30'
end
- resource_without :source do
+ context 'with conflict' do
+ it "should use 'svn update'" do
+ resource[:conflict] = 'theirs-full'
+ expects_chdir
+ provider.expects(:svn).with('--non-interactive', 'update',
+ '-r', @revision,
+ '--accept', resource.value(:conflict))
+ provider.revision = @revision
+ end
+ end
+ context 'without conflict' do
it "should use 'svn update'" do
expects_chdir
provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision)
@@ -82,8 +136,20 @@ describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do
before do
@revision = '30'
end
- resource_with :source do
+ context 'with conflict' do
+ it "should use 'svn switch'" do
+ resource[:source] = 'an-unimportant-value'
+ resource[:conflict] = 'theirs-full'
+ expects_chdir
+ provider.expects(:svn).with('--non-interactive', 'switch',
+ '-r', @revision, 'an-unimportant-value',
+ '--accept', resource.value(:conflict))
+ provider.revision = @revision
+ end
+ end
+ context 'without conflict' do
it "should use 'svn switch'" do
+ resource[:source] = 'an-unimportant-value'
expects_chdir
provider.expects(:svn).with('--non-interactive', 'switch', '-r', @revision, 'an-unimportant-value')
provider.revision = @revision