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