3 describe Puppet::Type.type(:vcsrepo).provider(:svn) do
5 let(:resource) { Puppet::Type.type(:vcsrepo).new({
9 :path => '/tmp/vcsrepo',
12 let(:provider) { resource.provider }
15 Puppet::Util.stubs(:which).with('git').returns('/usr/bin/git')
18 describe 'creating' do
19 context 'with source and revision' do
20 it "should execute 'svn checkout' with a revision" do
21 resource[:source] = 'exists'
22 resource[:revision] = '1'
23 provider.expects(:svn).with('--non-interactive', 'checkout', '-r',
24 resource.value(:revision),
25 resource.value(:source),
26 resource.value(:path))
30 context 'with source' do
31 it "should just execute 'svn checkout' without a revision" do
32 resource[:source] = 'exists'
33 provider.expects(:svn).with('--non-interactive', 'checkout',
34 resource.value(:source),
35 resource.value(:path))
40 context 'with fstype' do
41 it "should execute 'svnadmin create' with an '--fs-type' option" do
42 resource[:fstype] = 'ext4'
43 provider.expects(:svnadmin).with('create', '--fs-type',
44 resource.value(:fstype),
45 resource.value(:path))
49 context 'without fstype' do
50 it "should execute 'svnadmin create' without an '--fs-type' option" do
51 provider.expects(:svnadmin).with('create', resource.value(:path))
56 context "with depth" do
57 it "should execute 'svn checkout' with a depth" do
58 resource[:source] = 'exists'
59 resource[:depth] = 'infinity'
60 provider.expects(:svn).with('--non-interactive', 'checkout', '--depth', 'infinity',
61 resource.value(:source),
62 resource.value(:path))
67 context "with trust_server_cert" do
68 it "should execute 'svn checkout' with a trust-server-cert" do
69 resource[:source] = 'exists'
70 resource[:trust_server_cert] = true
71 provider.expects(:svn).with('--non-interactive', '--trust-server-cert', 'checkout',
72 resource.value(:source),
73 resource.value(:path))
79 describe 'destroying' do
80 it "it should remove the directory" do
86 describe "checking existence" do
87 it "should check for the directory" do
88 expects_directory?(true, resource.value(:path))
89 expects_directory?(true, File.join(resource.value(:path), '.svn'))
94 describe "checking the revision property" do
96 provider.expects(:svn).with('--non-interactive', 'info').returns(fixture(:svn_info))
98 it "should use 'svn info'" do
100 expect(provider.revision).to eq('4') # From 'Revision', not 'Last Changed Rev'
104 describe "setting the revision property" do
108 context 'with conflict' do
109 it "should use 'svn update'" do
110 resource[:conflict] = 'theirs-full'
112 provider.expects(:svn).with('--non-interactive', 'update',
114 '--accept', resource.value(:conflict))
115 provider.revision = @revision
118 context 'without conflict' do
119 it "should use 'svn update'" do
121 provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision)
122 provider.revision = @revision
127 describe "setting the revision property and repo source" do
131 context 'with conflict' do
132 it "should use 'svn switch'" do
133 resource[:source] = 'an-unimportant-value'
134 resource[:conflict] = 'theirs-full'
136 provider.expects(:svn).with('--non-interactive', 'switch',
137 '-r', @revision, 'an-unimportant-value',
138 '--accept', resource.value(:conflict))
139 provider.revision = @revision
142 context 'without conflict' do
143 it "should use 'svn switch'" do
144 resource[:source] = 'an-unimportant-value'
146 provider.expects(:svn).with('--non-interactive', 'switch', '-r', @revision, 'an-unimportant-value')
147 provider.revision = @revision