forked from puppetlabs/puppetlabs-concat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup_spec.rb
More file actions
115 lines (106 loc) · 3.12 KB
/
backup_spec.rb
File metadata and controls
115 lines (106 loc) · 3.12 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
require 'spec_helper_acceptance'
describe 'concat backup parameter' do
basedir = default.tmpdir('concat')
context 'when puppet' do
before(:all) do
pp = <<-MANIFEST
file { '#{basedir}':
ensure => directory,
}
file { '#{basedir}/file':
content => "old contents\n",
}
MANIFEST
apply_manifest(pp)
end
pp = <<-MANIFEST
concat { '#{basedir}/file':
backup => 'puppet',
}
concat::fragment { 'new file':
target => '#{basedir}/file',
content => 'new contents',
}
MANIFEST
it 'applies the manifest twice with "Filebucketed" stdout and no stderr' do
apply_manifest(pp, catch_failures: true) do |r|
expect(r.stdout).to match(%r{Filebucketed #{basedir}/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f})
end
apply_manifest(pp, catch_changes: true)
end
describe file("#{basedir}/file") do
it { is_expected.to be_file }
its(:content) { is_expected.to match %r{new contents} }
end
end
context 'when .backup' do
before(:all) do
pp = <<-MANIFEST
file { '#{basedir}':
ensure => directory,
}
file { '#{basedir}/file':
content => "old contents\n",
}
MANIFEST
apply_manifest(pp)
end
pp = <<-MANIFEST
concat { '#{basedir}/file':
backup => '.backup',
}
concat::fragment { 'new file':
target => '#{basedir}/file',
content => 'new contents',
}
MANIFEST
# XXX Puppet doesn't mention anything about filebucketing with a given
# extension like .backup
it 'applies the manifest twice no stderr' do
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
describe file("#{basedir}/file") do
it { is_expected.to be_file }
its(:content) { is_expected.to match %r{new contents} }
end
describe file("#{basedir}/file.backup") do
it { is_expected.to be_file }
its(:content) { is_expected.to match %r{old contents} }
end
end
# XXX The backup parameter uses validate_string() and thus can't be the
# boolean false value, but the string 'false' has the same effect in Puppet 3
context "when 'false'" do
before(:all) do
pp = <<-MANIFEST
file { '#{basedir}':
ensure => directory,
}
file { '#{basedir}/file':
content => "old contents\n",
}
MANIFEST
apply_manifest(pp)
end
pp = <<-MANIFEST
concat { '#{basedir}/file':
backup => '.backup',
}
concat::fragment { 'new file':
target => '#{basedir}/file',
content => 'new contents',
}
MANIFEST
it 'applies the manifest twice with no "Filebucketed" stdout and no stderr' do
apply_manifest(pp, catch_failures: true) do |r|
expect(r.stdout).not_to match(%r{Filebucketed})
end
apply_manifest(pp, catch_changes: true)
end
describe file("#{basedir}/file") do
it { is_expected.to be_file }
its(:content) { is_expected.to match %r{new contents} }
end
end
end