Update 3rdparty rabbitmq module
[mirror/dsa-puppet.git] / 3rdparty / modules / rabbitmq / spec / unit / puppet / type / rabbitmq_exchange_spec.rb
1 require 'spec_helper'
2 describe Puppet::Type.type(:rabbitmq_exchange) do
3   let(:exchange) do
4     Puppet::Type.type(:rabbitmq_exchange).new(
5       name: 'foo@bar',
6       type: :topic,
7       internal: false,
8       auto_delete: false,
9       durable: true
10     )
11   end
12
13   it 'accepts an exchange name' do
14     exchange[:name] = 'dan@pl'
15     expect(exchange[:name]).to eq('dan@pl')
16   end
17   it 'requires a name' do
18     expect do
19       Puppet::Type.type(:rabbitmq_exchange).new({})
20     end.to raise_error(Puppet::Error, 'Title or name must be provided')
21   end
22   it 'does not allow whitespace in the name' do
23     expect do
24       exchange[:name] = 'b r'
25     end.to raise_error(Puppet::Error, %r{Valid values match})
26   end
27   it 'does not allow names without @' do
28     expect do
29       exchange[:name] = 'b_r'
30     end.to raise_error(Puppet::Error, %r{Valid values match})
31   end
32
33   it 'accepts an exchange type' do
34     exchange[:type] = :direct
35     expect(exchange[:type]).to eq(:direct)
36   end
37   it 'requires a type' do
38     expect do
39       Puppet::Type.type(:rabbitmq_exchange).new(name: 'foo@bar')
40     end.to raise_error(%r{.*must set type when creating exchange.*})
41   end
42   it 'does not require a type when destroying' do
43     expect do
44       Puppet::Type.type(:rabbitmq_exchange).new(name: 'foo@bar', ensure: :absent)
45     end.not_to raise_error
46   end
47
48   it 'accepts a user' do
49     exchange[:user] = :root
50     expect(exchange[:user]).to eq(:root)
51   end
52
53   it 'accepts a password' do
54     exchange[:password] = :PaSsw0rD
55     expect(exchange[:password]).to eq(:PaSsw0rD)
56   end
57 end