Skip to content

Commit efd78b4

Browse files
author
Roberto Valentini
committed
Refactor Test
1 parent 543c1aa commit efd78b4

23 files changed

+441
-937
lines changed

manifests/files.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
String $options = 'defaults',
4040
$timeout = 300,
4141
String $cmd = 'dd',
42-
Bootlan $resize_existing = false,
42+
Boolean $resize_existing = false,
4343
$resize_margin = '50MB',
4444
Boolean $resize_verbose = false,
4545
) {

spec/acceptance/nodesets/Vagrantfile-vagrant_custom

Lines changed: 0 additions & 11 deletions
This file was deleted.

spec/acceptance/nodesets/centos-7-x64-vagrant_libvirt.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

spec/acceptance/nodesets/ubuntu-server-12042-x64.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

spec/acceptance/swap_file_class_spec.rb

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,57 @@
22

33
require 'spec_helper_acceptance'
44

5-
describe 'swap_file class', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
6-
context 'swap_file' do
7-
context 'ensure => present' do
8-
it 'works with no errors' do
9-
pp = <<-EOS
10-
class { 'swap_file':
11-
files => {
12-
'swapfile' => {
13-
ensure => 'present',
14-
},
15-
'use fallocate' => {
16-
swapfile => '/tmp/swapfile.fallocate',
17-
cmd => 'fallocate',
18-
},
19-
'remove swap file' => {
20-
ensure => 'absent',
21-
swapfile => '/tmp/swapfile.old',
22-
},
23-
},
24-
}
25-
EOS
26-
27-
# Run it twice and test for idempotency
28-
apply_manifest(pp, catch_failures: true)
29-
apply_manifest(pp, catch_changes: true)
30-
end
31-
32-
it 'contains the default swapfile' do
33-
shell('/sbin/swapon -s | grep /mnt/swap.1', acceptable_exit_codes: [0])
34-
end
5+
describe 'swap_file class' do
6+
after(:all) do
7+
pp = <<-EOS
8+
class { 'swap_file':
9+
files => {
10+
'swapfile' => {
11+
ensure => 'absent',
12+
},
13+
'use fallocate' => {
14+
swapfile => '/tmp/swapfile.fallocate',
15+
cmd => 'fallocate',
16+
ensure => absent,
17+
},
18+
'remove swap file' => {
19+
ensure => 'absent',
20+
swapfile => '/tmp/swapfile.old',
21+
},
22+
},
23+
}
24+
EOS
3525

36-
it 'contains the default fstab setting' do
37-
shell('cat /etc/fstab | grep /mnt/swap.1', acceptable_exit_codes: [0])
38-
shell('cat /etc/fstab | grep defaults', acceptable_exit_codes: [0])
39-
end
26+
apply_manifest(pp, catch_failures: true)
27+
end
4028

41-
it 'contains the default swapfile' do
42-
shell('/sbin/swapon -s | grep /tmp/swapfile.fallocate', acceptable_exit_codes: [0])
29+
context 'with multiple files config' do
30+
it_behaves_like 'an idempotent resource' do
31+
let(:manifest) do
32+
<<-PUPPET
33+
class { 'swap_file':
34+
files => {
35+
'swapfile' => {
36+
ensure => 'present',
37+
},
38+
'use fallocate' => {
39+
swapfile => '/tmp/swapfile.fallocate',
40+
cmd => 'fallocate',
41+
},
42+
'remove swap file' => {
43+
ensure => 'absent',
44+
swapfile => '/tmp/swapfile.old',
45+
},
46+
},
47+
}
48+
PUPPET
4349
end
50+
end
4451

45-
it 'contains the default fstab setting' do
46-
shell('cat /etc/fstab | grep /tmp/swapfile.fallocate', acceptable_exit_codes: [0])
47-
end
52+
describe file('/etc/fstab'), shell('/sbin/swapon -s') do
53+
its(:content) { is_expected.to match %r{/mnt/swap.1} }
54+
its(:content) { is_expected.to match %r{/tmp/swapfile.fallocate} }
55+
its(:content) { is_expected.not_to match %r{/tmp/swapfile.old} }
4856
end
4957
end
5058
end

spec/acceptance/swap_file_files_fallocate_command.rb

Lines changed: 0 additions & 28 deletions
This file was deleted.

spec/acceptance/swap_file_files_multiple_spec.rb

Lines changed: 0 additions & 34 deletions
This file was deleted.

spec/acceptance/swap_file_files_parameters_spec.rb

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)