2013-07-19 21:38:31 -04:00
|
|
|
Shindo.tests('Fog::Rackspace::Queues | claims', ['rackspace']) do
|
|
|
|
|
2013-10-10 11:25:35 -04:00
|
|
|
service = Fog::Rackspace::Queues.new
|
2013-07-19 21:38:31 -04:00
|
|
|
queue = service.queues.create({
|
|
|
|
:name => "fog_queue_#{Time.now.to_i.to_s}",
|
|
|
|
})
|
|
|
|
queue.messages.create({
|
|
|
|
:ttl => VALID_TTL,
|
|
|
|
:body => { :random => :body }
|
|
|
|
})
|
|
|
|
params = {
|
|
|
|
:ttl => VALID_TTL,
|
|
|
|
:grace => VALID_GRACE
|
|
|
|
}
|
|
|
|
|
|
|
|
begin
|
2014-01-20 17:29:38 -05:00
|
|
|
collection_tests(queue.claims, params)
|
2013-07-19 21:38:31 -04:00
|
|
|
|
|
|
|
tests('creating claims when there are no messages') do
|
|
|
|
|
|
|
|
before do
|
|
|
|
#clear all message from queue
|
|
|
|
queue.messages.all.each do |message|
|
|
|
|
message.destroy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#create(#{params.inspect}) => with no messages does not show up in claim list") do
|
|
|
|
returns(false) { queue.claims.create(params) }
|
|
|
|
returns(true) { queue.claims.empty? }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('create claims when there are messages') do
|
|
|
|
|
|
|
|
before do
|
|
|
|
queue.messages.create({
|
|
|
|
:ttl => VALID_TTL,
|
|
|
|
:body => { :random => :body }
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#create(#{params.inspect}) => with messages does show up in claim list") do
|
|
|
|
returns(true) do
|
|
|
|
queue.claims.create(params).instance_of? Fog::Rackspace::Queues::Claim
|
|
|
|
end
|
|
|
|
returns(false) { queue.claims.empty? }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
ensure
|
|
|
|
queue.destroy
|
|
|
|
end
|
|
|
|
end
|