Update rabbitmq module
[mirror/dsa-puppet.git] / 3rdparty / modules / rabbitmq / spec / unit / puppet / type / rabbitmq_binding_spec.rb
1 require 'spec_helper'
2 describe Puppet::Type.type(:rabbitmq_binding) do
3   let(:binding) do
4     Puppet::Type.type(:rabbitmq_binding).new(
5       name: 'foo@blub@bar',
6       destination_type: :queue
7     )
8   end
9
10   it 'accepts an queue name' do
11     binding[:name] = 'dan@dude@pl'
12     expect(binding[:name]).to eq('dan@dude@pl')
13   end
14   it 'requires a name' do
15     expect do
16       Puppet::Type.type(:rabbitmq_binding).new({})
17     end.to raise_error(Puppet::Error, 'Title or name must be provided')
18   end
19   it 'errors when missing source' do
20     expect do
21       Puppet::Type.type(:rabbitmq_binding).new(
22         name: 'test binding',
23         destination: 'foobar'
24       )
25     end.to raise_error(Puppet::Error, %r{`source` must be defined})
26   end
27   it 'errors when missing destination' do
28     expect do
29       Puppet::Type.type(:rabbitmq_binding).new(
30         name: 'test binding',
31         source: 'foobar'
32       )
33     end.to raise_error(Puppet::Error, %r{`destination` must be defined})
34   end
35   it 'accepts an binding destination_type' do
36     binding[:destination_type] = :exchange
37     expect(binding[:destination_type]).to eq(:exchange)
38   end
39   it 'accepts a user' do
40     binding[:user] = :root
41     expect(binding[:user]).to eq(:root)
42   end
43   it 'accepts a password' do
44     binding[:password] = :PaSsw0rD
45     expect(binding[:password]).to eq(:PaSsw0rD)
46   end
47 end