Skip to content

Commit

Permalink
Mock the create_queue call.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash Wilson committed Jan 21, 2014
1 parent c434002 commit f2da5bb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
20 changes: 18 additions & 2 deletions lib/fog/rackspace/queues.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,30 @@ def client_id=(client_id)
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

Expand Down
17 changes: 16 additions & 1 deletion lib/fog/rackspace/requests/queues/create_queue.rb
Original file line number Diff line number Diff line change
@@ -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.
#
Expand All @@ -22,6 +22,21 @@ def create_queue(queue_name)
)
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

0 comments on commit f2da5bb

Please sign in to comment.