mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Mock the create_queue call.
This commit is contained in:
parent
c434002e99
commit
f2da5bba86
2 changed files with 34 additions and 3 deletions
|
@ -90,14 +90,30 @@ module Fog
|
|||
class Mock < Fog::Rackspace::Service
|
||||
include Common
|
||||
|
||||
# An in-memory Queue implementation.
|
||||
class MockQueue
|
||||
attr_accessor :metadata
|
||||
|
||||
def initialize
|
||||
@metadata = {}
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(options = {})
|
||||
apply_options(options)
|
||||
authenticate
|
||||
endpoint_uri
|
||||
end
|
||||
|
||||
def request(params)
|
||||
Fog::Mock.not_implemented
|
||||
# FIXME Refactor commonalities from Fog::Rackspace::Storage to... somewhere.
|
||||
def self.data
|
||||
@data ||= Hash.new do |hash, key|
|
||||
hash[key] = {}
|
||||
end
|
||||
end
|
||||
|
||||
def data
|
||||
self.class.data[@rackspace_username]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class Queues
|
||||
class Real
|
||||
|
||||
class Real
|
||||
# This operation creates a new queue.
|
||||
# The body of the request is empty.
|
||||
#
|
||||
|
@ -22,6 +22,21 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def create_queue(queue_name)
|
||||
existed = ! data[queue_name].nil?
|
||||
|
||||
unless existed
|
||||
data[queue_name] = MockQueue.new
|
||||
end
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = existed ? 201 : 204
|
||||
response
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue