3 describe Puppet::Type.type(:vcsrepo).provider(:cvs_provider) do
5 let(:resource) { Puppet::Type.type(:vcsrepo).new({
14 let(:provider) { resource.provider }
17 Puppet::Util.stubs(:which).with('cvs').returns('/usr/bin/cvs')
20 describe 'creating' do
21 context "with a source" do
22 it "should execute 'cvs checkout'" do
23 resource[:source] = ':ext:source@example.com:/foo/bar'
24 resource[:revision] = 'an-unimportant-value'
26 provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-r', 'an-unimportant-value', '-d', 'test', 'bar')
30 it "should just execute 'cvs checkout' without a revision" do
31 resource[:source] = ':ext:source@example.com:/foo/bar'
32 resource.delete(:revision)
33 provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source)))
37 context "with a compression" do
38 it "should just execute 'cvs checkout' without a revision" do
39 resource[:source] = ':ext:source@example.com:/foo/bar'
40 resource[:compression] = '3'
41 resource.delete(:revision)
42 provider.expects(:cvs).with('-d', resource.value(:source), '-z', '3', 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source)))
48 context "when a source is not given" do
49 it "should execute 'cvs init'" do
50 resource.delete(:source)
51 provider.expects(:cvs).with('-d', resource.value(:path), 'init')
57 describe 'destroying' do
58 it "it should remove the directory" do
63 describe "checking existence" do
64 it "should check for the CVS directory with source" do
65 resource[:source] = ':ext:source@example.com:/foo/bar'
66 File.expects(:directory?).with(File.join(resource.value(:path), 'CVS'))
70 it "should check for the CVSROOT directory without source" do
71 resource.delete(:source)
72 File.expects(:directory?).with(File.join(resource.value(:path), 'CVSROOT'))
77 describe "checking the revision property" do
79 @tag_file = File.join(resource.value(:path), 'CVS', 'Tag')
82 context "when CVS/Tag exists" do
85 File.expects(:exist?).with(@tag_file).returns(true)
87 it "should read CVS/Tag" do
88 File.expects(:read).with(@tag_file).returns("T#{@tag}")
89 provider.revision.should == @tag
93 context "when CVS/Tag does not exist" do
95 File.expects(:exist?).with(@tag_file).returns(false)
98 provider.revision.should == 'HEAD'
103 describe "when setting the revision property" do
108 it "should use 'cvs update -dr'" do
110 provider.expects(:cvs).with('update', '-dr', @tag, '.')
111 provider.revision = @tag