X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Frabbitmq%2Fspec%2Funit%2Fpuppet%2Ftype%2Frabbitmq_queue_spec.rb;fp=3rdparty%2Fmodules%2Frabbitmq%2Fspec%2Funit%2Fpuppet%2Ftype%2Frabbitmq_queue_spec.rb;h=4fd7b34efdf2f9cffaed7a28b41245637efb426f;hb=abf5299108b021bebf2fb9cd7519898e3baf29bd;hp=0000000000000000000000000000000000000000;hpb=a82772daaacb48fa7d88ef1d1216c731bdc15187;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/rabbitmq/spec/unit/puppet/type/rabbitmq_queue_spec.rb b/3rdparty/modules/rabbitmq/spec/unit/puppet/type/rabbitmq_queue_spec.rb new file mode 100644 index 000000000..4fd7b34ef --- /dev/null +++ b/3rdparty/modules/rabbitmq/spec/unit/puppet/type/rabbitmq_queue_spec.rb @@ -0,0 +1,60 @@ +require 'puppet' +require 'puppet/type/rabbitmq_queue' +require 'json' +describe Puppet::Type.type(:rabbitmq_queue) do + before :each do + @queue = Puppet::Type.type(:rabbitmq_queue).new( + :name => 'foo@bar', + :durable => :true, + :arguments => { + 'x-message-ttl' => 45, + 'x-dead-letter-exchange' => 'deadexchange' + } + ) + end + it 'should accept an queue name' do + @queue[:name] = 'dan@pl' + @queue[:name].should == 'dan@pl' + end + it 'should require a name' do + expect { + Puppet::Type.type(:rabbitmq_queue).new({}) + }.to raise_error(Puppet::Error, 'Title or name must be provided') + end + it 'should not allow whitespace in the name' do + expect { + @queue[:name] = 'b r' + }.to raise_error(Puppet::Error, /Valid values match/) + end + it 'should not allow names without @' do + expect { + @queue[:name] = 'b_r' + }.to raise_error(Puppet::Error, /Valid values match/) + end + + it 'should accept an arguments with numbers value' do + @queue[:arguments] = {'x-message-ttl' => 30} + @queue[:arguments].to_json.should == "{\"x-message-ttl\":30}" + @queue[:arguments]['x-message-ttl'].should == 30 + end + + it 'should accept an arguments with string value' do + @queue[:arguments] = {'x-dead-letter-exchange' => 'catchallexchange'} + @queue[:arguments].to_json.should == "{\"x-dead-letter-exchange\":\"catchallexchange\"}" + end + + it 'should accept an queue durable' do + @queue[:durable] = :true + @queue[:durable].should == :true + end + + it 'should accept a user' do + @queue[:user] = :root + @queue[:user].should == :root + end + + it 'should accept a password' do + @queue[:password] = :PaSsw0rD + @queue[:password].should == :PaSsw0rD + end +end