]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/rabbitmq/spec/unit/puppet/type/rabbitmq_queue_spec.rb
move to puppetlabs rabbitmq module
[dsa-puppet.git] / 3rdparty / modules / rabbitmq / spec / unit / puppet / type / rabbitmq_queue_spec.rb
1 require 'puppet'
2 require 'puppet/type/rabbitmq_queue'
3 require 'json'
4 describe Puppet::Type.type(:rabbitmq_queue) do
5   before :each do
6     @queue = Puppet::Type.type(:rabbitmq_queue).new(
7       :name => 'foo@bar',
8       :durable => :true,
9       :arguments => {
10         'x-message-ttl' => 45,
11         'x-dead-letter-exchange' => 'deadexchange'
12       }
13     )
14   end
15   it 'should accept an queue name' do
16     @queue[:name] = 'dan@pl'
17     @queue[:name].should == 'dan@pl'
18   end
19   it 'should require a name' do
20     expect {
21       Puppet::Type.type(:rabbitmq_queue).new({})
22     }.to raise_error(Puppet::Error, 'Title or name must be provided')
23   end
24   it 'should not allow whitespace in the name' do
25     expect {
26       @queue[:name] = 'b r'
27     }.to raise_error(Puppet::Error, /Valid values match/)
28   end
29   it 'should not allow names without @' do
30     expect {
31       @queue[:name] = 'b_r'
32     }.to raise_error(Puppet::Error, /Valid values match/)
33   end
34
35   it 'should accept an arguments with numbers value' do
36     @queue[:arguments] = {'x-message-ttl' => 30}
37     @queue[:arguments].to_json.should == "{\"x-message-ttl\":30}"
38     @queue[:arguments]['x-message-ttl'].should == 30
39   end
40
41   it 'should accept an arguments with string value' do
42     @queue[:arguments] = {'x-dead-letter-exchange' => 'catchallexchange'}
43     @queue[:arguments].to_json.should == "{\"x-dead-letter-exchange\":\"catchallexchange\"}"
44   end
45
46   it 'should accept an queue durable' do
47     @queue[:durable] = :true
48     @queue[:durable].should == :true
49   end
50
51   it 'should accept a user' do
52     @queue[:user] = :root
53     @queue[:user].should == :root
54   end
55
56   it 'should accept a password' do
57     @queue[:password] = :PaSsw0rD
58     @queue[:password].should == :PaSsw0rD
59   end
60 end