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))
57 describe 'destroying' do
58 it "it should remove the directory" do
64 describe "checking existence" do
65 it "should check for the directory" do
66 expects_directory?(true, resource.value(:path))
67 expects_directory?(true, File.join(resource.value(:path), '.svn'))
72 describe "checking the revision property" do
74 provider.expects(:svn).with('--non-interactive', 'info').returns(fixture(:svn_info))
76 it "should use 'svn info'" do
78 expect(provider.revision).to eq('4') # From 'Revision', not 'Last Changed Rev'
82 describe "setting the revision property" do
86 it "should use 'svn update'" do
88 provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision)
89 provider.revision = @revision
93 describe "setting the revision property and repo source" do
97 it "should use 'svn switch'" do
98 resource[:source] = 'an-unimportant-value'
100 provider.expects(:svn).with('--non-interactive', 'switch', '-r', @revision, 'an-unimportant-value')
101 provider.revision = @revision