Skip to content

Commit

Permalink
Improve rabbitmq type acceptance tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Colleen Murphy committed Dec 17, 2014
1 parent dac9d75 commit 43906f5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
11 changes: 6 additions & 5 deletions spec/acceptance/policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ class { '::rabbitmq':
EOS

apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end

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

end
Expand Down
9 changes: 6 additions & 3 deletions spec/acceptance/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ class { '::rabbitmq':
EOS

apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end

describe command('rabbitmqctl list_users | grep dan') do
its(:stdout) { should match /dan/ }
its(:stdout) { should match /administrator/ }
it 'should have the user' do
shell('rabbitmqctl list_users') do |r|
expect(r.stdout).to match(/dan.*administrator/)
expect(r.exit_code).to be_zero
end
end

end
Expand Down
8 changes: 6 additions & 2 deletions spec/acceptance/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ class { '::rabbitmq':
EOS

apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end

describe command('rabbitmqctl list_vhosts | grep myhost') do
its(:stdout) { should match /myhost/ }
it 'should have the vhost' do
shell('rabbitmqctl list_vhosts') do |r|
expect(r.stdout).to match(/myhost/)
expect(r.exit_code).to be_zero
end
end

end
Expand Down

0 comments on commit 43906f5

Please sign in to comment.