Skip to content

Commit

Permalink
Merge 24a02cc into 468fe86
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudy-Zidan committed Aug 21, 2020
2 parents 468fe86 + 24a02cc commit ea3470b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/bunny_mock/queue.rb
Expand Up @@ -236,6 +236,16 @@ def delete
@deleted = true
end

##
# Check if this queue will survive broker restart
#
# @return [Boolean] true if this queue is durable, false otherwise
# @api public
#
def durable?
@opts[:durable] == true
end

private

# @private
Expand Down
18 changes: 17 additions & 1 deletion spec/unit/bunny_mock/queue_spec.rb
Expand Up @@ -206,7 +206,7 @@
consumer = proc do |_delivery, _headers, body|
expect(body).to eq('test')
end

@queue.subscribe_with consumer
@queue.publish 'test'
end
Expand Down Expand Up @@ -234,4 +234,20 @@
expect(@session.queue_exists?(@queue.name)).to be_falsey
end
end

context '#durable?' do
it 'should return false as default' do
expect(@queue.durable?).to be_falsey
end

it 'should return true if is durable' do
@durable_queue = @channel.queue 'testing.durable.q', { durable: true }
expect(@durable_queue.durable?).to be_truthy
end

it 'should return false if is not durable' do
@not_durable_queue = @channel.queue 'testing.not.durable.q', { durable: false }
expect(@not_durable_queue.durable?).to be_falsey
end
end
end

0 comments on commit ea3470b

Please sign in to comment.