Skip to content

Commit e34ae6e

Browse files
committed
acceptance tests: ensure code is idempotent
1 parent 922395b commit e34ae6e

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

spec/acceptance/postgresql_psql_spec.rb

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ class { 'postgresql::server': } ->
1212
}
1313
MANIFEST
1414
it 'alwayses run SQL' do
15-
apply_manifest(pp_one, catch_failures: true)
16-
apply_manifest(pp_one, expect_changes: true)
15+
idempotent_apply(pp_one)
1716
end
1817

1918
pp_two = <<-MANIFEST
@@ -26,8 +25,7 @@ class { 'postgresql::server': } ->
2625
}
2726
MANIFEST
2827
it 'runs some SQL when the unless query returns no rows' do
29-
apply_manifest(pp_two, catch_failures: true)
30-
apply_manifest(pp_two, expect_changes: true)
28+
idempotent_apply(pp_two)
3129
end
3230

3331
pp_three = <<-MANIFEST
@@ -54,8 +52,7 @@ class { 'postgresql::server': } ->
5452
}
5553
MANIFEST
5654
it 'does not run SQL when refreshed and the unless query returns rows' do
57-
apply_manifest(pp_four, catch_failures: true)
58-
apply_manifest(pp_four, expect_changes: true)
55+
idempotent_apply(pp_four)
5956
end
6057

6158
context 'with refreshonly' do
@@ -85,8 +82,7 @@ class { 'postgresql::server': } ->
8582
}
8683
MANIFEST
8784
it 'runs SQL when refreshed and the unless query returns no rows' do
88-
apply_manifest(pp_six, catch_failures: true)
89-
apply_manifest(pp_six, expect_changes: true)
85+
idempotent_apply(pp_six)
9086
end
9187

9288
pp_seven = <<-MANIFEST.unindent
@@ -101,8 +97,7 @@ class { 'postgresql::server': } ->
10197
}
10298
MANIFEST
10399
it 'does not run SQL when refreshed and the unless query returns rows' do
104-
apply_manifest(pp_seven, catch_failures: true)
105-
apply_manifest(pp_seven, expect_changes: true)
100+
idempotent_apply(pp_seven)
106101
end
107102
end
108103

@@ -116,8 +111,7 @@ class { 'postgresql::server': } ->
116111
}
117112
MANIFEST
118113
it 'does not run some SQL when the onlyif query returns no rows' do
119-
apply_manifest(pp_eight, catch_failures: true)
120-
apply_manifest(pp_eight, catch_changes: true)
114+
idempotent_apply(pp_eight)
121115
end
122116

123117
pp_nine = <<-MANIFEST
@@ -130,8 +124,7 @@ class { 'postgresql::server': } ->
130124
}
131125
MANIFEST
132126
it 'runs SQL when the onlyif query returns rows' do
133-
apply_manifest(pp_nine, catch_failures: true)
134-
apply_manifest(pp_nine, expect_changes: true)
127+
idempotent_apply(pp_nine)
135128
end
136129

137130
context 'when setting sensitive => true' do

spec/acceptance/server_instance_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,6 @@ class { 'postgresql::server':
156156

157157
it 'installs postgres instance test1' do
158158
export_locales('en_US.UTF-8 ')
159-
apply_manifest(pp, catch_failures: true)
159+
idempotent_apply(pp)
160160
end
161161
end

0 commit comments

Comments
 (0)