Skip to content

Commit 43906f5

Browse files
author
Colleen Murphy
committed
Improve rabbitmq type acceptance tests
This patch adds checks for idempotency and improves the shell command syntax to contain one test at a time and use rspec tools to check output and exit codes.
1 parent dac9d75 commit 43906f5

3 files changed

Lines changed: 18 additions & 10 deletions

File tree

spec/acceptance/policy_spec.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ class { '::rabbitmq':
3333
EOS
3434

3535
apply_manifest(pp, :catch_failures => true)
36+
apply_manifest(pp, :catch_changes => true)
3637
end
3738

38-
describe command('rabbitmqctl list_policies -p myhost') do
39-
its(:stdout) { should match /myhost/ }
40-
its(:stdout) { should match /ha-all/ }
41-
its(:stdout) { should match /ha-sync-mode/ }
42-
its(:stdout) { should match /\.\*/ }
39+
it 'should have the policy' do
40+
shell('rabbitmqctl list_policies -p myhost') do |r|
41+
expect(r.stdout).to match(/myhost.*ha-all.*ha-sync-mode/)
42+
expect(r.exit_code).to be_zero
43+
end
4344
end
4445

4546
end

spec/acceptance/user_spec.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ class { '::rabbitmq':
2424
EOS
2525

2626
apply_manifest(pp, :catch_failures => true)
27+
apply_manifest(pp, :catch_changes => true)
2728
end
2829

29-
describe command('rabbitmqctl list_users | grep dan') do
30-
its(:stdout) { should match /dan/ }
31-
its(:stdout) { should match /administrator/ }
30+
it 'should have the user' do
31+
shell('rabbitmqctl list_users') do |r|
32+
expect(r.stdout).to match(/dan.*administrator/)
33+
expect(r.exit_code).to be_zero
34+
end
3235
end
3336

3437
end

spec/acceptance/vhost_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ class { '::rabbitmq':
2323
EOS
2424

2525
apply_manifest(pp, :catch_failures => true)
26+
apply_manifest(pp, :catch_changes => true)
2627
end
2728

28-
describe command('rabbitmqctl list_vhosts | grep myhost') do
29-
its(:stdout) { should match /myhost/ }
29+
it 'should have the vhost' do
30+
shell('rabbitmqctl list_vhosts') do |r|
31+
expect(r.stdout).to match(/myhost/)
32+
expect(r.exit_code).to be_zero
33+
end
3034
end
3135

3236
end

0 commit comments

Comments
 (0)