]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/concat/spec/acceptance/backup_spec.rb
try if downgrading to 1.2.2 solves my problem
[dsa-puppet.git] / 3rdparty / modules / concat / spec / acceptance / backup_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'concat backup parameter' do
4   basedir = default.tmpdir('concat')
5   context '=> puppet' do
6     before(:all) do
7       pp = <<-EOS
8         file { '#{basedir}':
9           ensure => directory,
10         }
11         file { '#{basedir}/file':
12           content => "old contents\n",
13         }
14       EOS
15       apply_manifest(pp)
16     end
17     pp = <<-EOS
18       concat { '#{basedir}/file':
19         backup => 'puppet',
20       }
21       concat::fragment { 'new file':
22         target  => '#{basedir}/file',
23         content => 'new contents',
24       }
25     EOS
26
27     it 'applies the manifest twice with "Filebucketed" stdout and no stderr' do
28       apply_manifest(pp, :catch_failures => true) do |r|
29         expect(r.stdout).to match(/Filebucketed #{basedir}\/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f/) # sum is for file contents of 'old contents'
30       end
31       apply_manifest(pp, :catch_changes => true)
32     end
33
34     describe file("#{basedir}/file") do
35       it { should be_file }
36       its(:content) { should match /new contents/ }
37     end
38   end
39
40   context '=> .backup' do
41     before(:all) do
42       pp = <<-EOS
43         file { '#{basedir}':
44           ensure => directory,
45         }
46         file { '#{basedir}/file':
47           content => "old contents\n",
48         }
49       EOS
50       apply_manifest(pp)
51     end
52     pp = <<-EOS
53       concat { '#{basedir}/file':
54         backup => '.backup',
55       }
56       concat::fragment { 'new file':
57         target  => '#{basedir}/file',
58         content => 'new contents',
59       }
60     EOS
61
62     # XXX Puppet doesn't mention anything about filebucketing with a given
63     # extension like .backup
64     it 'applies the manifest twice  no stderr' do
65       apply_manifest(pp, :catch_failures => true)
66       apply_manifest(pp, :catch_changes => true)
67     end
68
69     describe file("#{basedir}/file") do
70       it { should be_file }
71       its(:content) { should match /new contents/ }
72     end
73     describe file("#{basedir}/file.backup") do
74       it { should be_file }
75       its(:content) { should match /old contents/ }
76     end
77   end
78
79   # XXX The backup parameter uses validate_string() and thus can't be the
80   # boolean false value, but the string 'false' has the same effect in Puppet 3
81   context "=> 'false'" do
82     before(:all) do
83       pp = <<-EOS
84         file { '#{basedir}':
85           ensure => directory,
86         }
87         file { '#{basedir}/file':
88           content => "old contents\n",
89         }
90       EOS
91       apply_manifest(pp)
92     end
93     pp = <<-EOS
94       concat { '#{basedir}/file':
95         backup => '.backup',
96       }
97       concat::fragment { 'new file':
98         target  => '#{basedir}/file',
99         content => 'new contents',
100       }
101     EOS
102
103     it 'applies the manifest twice with no "Filebucketed" stdout and no stderr' do
104       apply_manifest(pp, :catch_failures => true) do |r|
105         expect(r.stdout).to_not match(/Filebucketed/)
106       end
107       apply_manifest(pp, :catch_changes => true)
108     end
109
110     describe file("#{basedir}/file") do
111       it { should be_file }
112       its(:content) { should match /new contents/ }
113     end
114   end
115 end