- it 'should call rabbitmqadmin to create' do
- @provider.expects(:rabbitmqadmin).with('declare', 'binding', '--vhost=/', '--user=colin', '--password=secret', '-c', '/etc/rabbitmq/rabbitmqadmin.conf', 'source=source', 'destination=test2', 'arguments={}', 'routing_key=blablubd', 'destination_type=queue')
- @provider.create
+ context 'specifying credentials' do
+ let(:resource) do
+ Puppet::Type::Rabbitmq_binding.new(
+ name: 'source@test2@/',
+ destination_type: :queue,
+ routing_key: 'blablubd',
+ arguments: {},
+ user: 'colin',
+ password: 'secret'
+ )
+ end
+ let(:provider) { provider_class.new(resource) }
+
+ it 'calls rabbitmqadmin to create' do
+ provider.expects(:rabbitmqadmin).with(
+ 'declare', 'binding', '--vhost=/', '--user=colin', '--password=secret', '-c', '/etc/rabbitmq/rabbitmqadmin.conf',
+ 'source=source', 'destination=test2', 'arguments={}', 'routing_key=blablubd', 'destination_type=queue'
+ )
+ provider.create
+ end
+ end
+
+ context 'new queue_bindings' do
+ let(:resource) do
+ Puppet::Type::Rabbitmq_binding.new(
+ name: 'binding1',
+ source: 'exchange1',
+ destination: 'destqueue',
+ destination_type: :queue,
+ routing_key: 'blablubd',
+ arguments: {}
+ )
+ end
+ let(:provider) { provider_class.new(resource) }
+
+ it 'calls rabbitmqadmin to create' do
+ provider.expects(:rabbitmqadmin).with(
+ 'declare', 'binding', '--vhost=/', '--user=guest', '--password=guest', '-c', '/etc/rabbitmq/rabbitmqadmin.conf',
+ 'source=exchange1', 'destination=destqueue', 'arguments={}', 'routing_key=blablubd', 'destination_type=queue'
+ )
+ provider.create
+ end
+ end
+ end
+
+ describe '#destroy' do
+ it 'calls rabbitmqadmin to destroy' do
+ provider.expects(:rabbitmqadmin).with(
+ 'delete', 'binding', '--vhost=/', '--user=guest', '--password=guest', '-c', '/etc/rabbitmq/rabbitmqadmin.conf',
+ 'source=source', 'destination_type=queue', 'destination=target', 'properties_key=blablub'
+ )
+ provider.destroy