Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / concat / spec / acceptance / backup_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'concat backup parameter' do
4   before(:all) do
5     @basedir = setup_test_directory
6   end
7
8   describe 'when puppet' do
9     let(:pp) do
10       <<-MANIFEST
11         concat { '#{@basedir}/file':
12           backup => 'puppet',
13         }
14         concat::fragment { 'new file':
15           target  => '#{@basedir}/file',
16           content => 'new contents',
17         }
18       MANIFEST
19     end
20
21     it 'applies the manifest twice with "Filebucketed" stdout and no stderr' do
22       expect(apply_manifest(pp, catch_failures: true, debug: true).stdout).to match(%r{Filebucketed.*to puppet with sum.*})
23       apply_manifest(pp, catch_changes: true)
24       expect(file("#{@basedir}/file")).to be_file
25       expect(file("#{@basedir}/file").content).to match %r{new contents}
26     end
27   end
28
29   describe 'when .backup' do
30     let(:pp) do
31       <<-MANIFEST
32       concat { '#{@basedir}/file':
33         backup => '.backup',
34       }
35       concat::fragment { 'new file':
36         target  => '#{@basedir}/file',
37         content => 'backup extension',
38       }
39       MANIFEST
40     end
41
42     # XXX Puppet doesn't mention anything about filebucketing with a given
43     # extension like .backup
44     it 'applies the manifest twice no stderr' do
45       idempotent_apply(pp)
46       expect(file("#{@basedir}/file")).to be_file
47       expect(file("#{@basedir}/file").content).to match %r{backup extension}
48       expect(file("#{@basedir}/file.backup")).to be_file
49       expect(file("#{@basedir}/file.backup").content).to match %r{new contents}
50     end
51   end
52
53   # XXX The backup parameter uses validate_string() and thus can't be the
54   # boolean false value, but the string 'false' has the same effect in Puppet 3
55   describe "when 'false'" do
56     let(:pp) do
57       <<-MANIFEST
58       concat { '#{@basedir}/file':
59         backup => '.backup',
60       }
61       concat::fragment { 'new file':
62         target  => '#{@basedir}/file',
63         content => 'new contents',
64       }
65     MANIFEST
66     end
67
68     it 'applies the manifest twice with no "Filebucketed" stdout and no stderr' do
69       apply_manifest(pp, catch_failures: true) do |r|
70         expect(r.stdout).not_to match(%r{Filebucketed})
71       end
72       apply_manifest(pp, catch_changes: true)
73       expect(file("#{@basedir}/file")).to be_file
74       expect(file("#{@basedir}/file").content).to match %r{new contents}
75     end
76   end
77 end