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' without a trust-server-cert" do
69 resource[:source] = 'exists'
70 resource[:trust_server_cert] = :false
71 provider.expects(:svn).with('--non-interactive', 'checkout',
72 resource.value(:source),
73 resource.value(:path))
76 it "should execute 'svn checkout' with a trust-server-cert" do
77 resource[:source] = 'exists'
78 resource[:trust_server_cert] = :true
79 provider.expects(:svn).with('--non-interactive', '--trust-server-cert', 'checkout',
80 resource.value(:source),
81 resource.value(:path))
87 describe 'destroying' do
88 it "it should remove the directory" do
94 describe "checking existence" do
95 it "should check for the directory" do
96 expects_directory?(true, resource.value(:path))
97 expects_directory?(true, File.join(resource.value(:path), '.svn'))
102 describe "checking the revision property" do
104 provider.expects(:svn).with('--non-interactive', 'info').returns(fixture(:svn_info))
106 it "should use 'svn info'" do
108 expect(provider.revision).to eq('4') # From 'Revision', not 'Last Changed Rev'
112 describe "setting the revision property" do
116 context 'with conflict' do
117 it "should use 'svn update'" do
118 resource[:conflict] = 'theirs-full'
120 provider.expects(:svn).with('--non-interactive', 'update',
122 '--accept', resource.value(:conflict))
123 provider.revision = @revision
126 context 'without conflict' do
127 it "should use 'svn update'" do
129 provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision)
130 provider.revision = @revision
135 describe "setting the revision property and repo source" do
139 context 'with conflict' do
140 it "should use 'svn switch'" do
141 resource[:source] = 'an-unimportant-value'
142 resource[:conflict] = 'theirs-full'
144 provider.expects(:svn).with('--non-interactive', 'switch',
145 '-r', @revision, 'an-unimportant-value',
146 '--accept', resource.value(:conflict))
147 provider.revision = @revision
150 context 'without conflict' do
151 it "should use 'svn switch'" do
152 resource[:source] = 'an-unimportant-value'
154 provider.expects(:svn).with('--non-interactive', 'switch', '-r', @revision, 'an-unimportant-value')
155 provider.revision = @revision