1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Store mock stacks in memory to make tests more realistic

This commit is contained in:
Thomas Kadauke 2013-06-04 16:00:39 +02:00 committed by Dan Prince
parent 9457089347
commit 704e33e7d8
5 changed files with 24 additions and 4 deletions

View file

@ -28,7 +28,11 @@ module Fog
attr_reader :current_tenant
def self.data
@data ||= {}
@data ||= Hash.new do |hash, key|
hash[key] = {
:stacks => {}
}
end
end
def self.reset

View file

@ -32,6 +32,18 @@ module Fog
class Mock
def create_stack(stack_name, options = {})
stack_id = Fog::Mock.random_hex(32)
stack = self.data[:stacks][stack_id] = {
'id' => stack_id,
'stack_name' => stack_name,
'links' => [],
'description' => options[:description],
'stack_status' => 'CREATE_COMPLETE',
'stack_status_reason' => 'Stack successfully created',
'creation_time' => Time.now,
'updated_time' => Time.now
}
response = Excon::Response.new
response.status = 202
response.body = {}

View file

@ -20,9 +20,11 @@ module Fog
end
end
class Mock
def delete_stack(stack_name, stack_id)
self.data[:stacks].delete(stack_id)
response = Excon::Response.new
response.status = 202
response.body = {}

View file

@ -35,8 +35,10 @@ module Fog
class Mock
def list_stacks(options = {})
stacks = self.data[:stacks].values
Excon::Response.new(
:body => { 'stacks' => [] },
:body => { 'stacks' => stacks },
:status => 200
)
end

View file

@ -3,7 +3,7 @@ Shindo.tests('Fog::Orchestration[:openstack] | stack requests', ['openstack']) d
'links' => Array,
'id' => String,
'stack_name' => String,
'description' => String,
'description' => Fog::Nullable::String,
'stack_status' => String,
'stack_status_reason' => String,
'creation_time' => Time,