summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/provider/vcsrepo/svn_spec.rb
blob: 75d58f97f43be34eba63da558c9f2f9362b12afc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
require 'spec_helper'

describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do

  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
      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
    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
      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
      end
    end
  end

  describe 'destroying' do
    it "it should remove the directory" do
      expects_rm_rf
      provider.destroy
    end
  end

  describe "checking existence" do
    it "should check for the directory" do
      expects_directory?(true, File.join(resource.value(:path), '.svn'))
      provider.exists?
    end
  end

  describe "checking the revision property" do
    before do
      provider.expects(:svn).with('--non-interactive', 'info').returns(fixture(:svn_info))
    end
    it "should use 'svn info'" do
      expects_chdir
      provider.revision.should == '3' # From 'Last Changed Rev', not 'Revision'
    end
  end

  describe "setting the revision property" do
    before do
      @revision = '30'
    end
    it "should use 'svn update'" do
      expects_chdir
      provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision)
      provider.revision = @revision
    end
  end

end