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:
parent
9457089347
commit
704e33e7d8
5 changed files with 24 additions and 4 deletions
|
@ -28,7 +28,11 @@ module Fog
|
||||||
attr_reader :current_tenant
|
attr_reader :current_tenant
|
||||||
|
|
||||||
def self.data
|
def self.data
|
||||||
@data ||= {}
|
@data ||= Hash.new do |hash, key|
|
||||||
|
hash[key] = {
|
||||||
|
:stacks => {}
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.reset
|
def self.reset
|
||||||
|
|
|
@ -32,6 +32,18 @@ module Fog
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
def create_stack(stack_name, options = {})
|
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 = Excon::Response.new
|
||||||
response.status = 202
|
response.status = 202
|
||||||
response.body = {}
|
response.body = {}
|
||||||
|
|
|
@ -20,9 +20,11 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
def delete_stack(stack_name, stack_id)
|
def delete_stack(stack_name, stack_id)
|
||||||
|
self.data[:stacks].delete(stack_id)
|
||||||
|
|
||||||
response = Excon::Response.new
|
response = Excon::Response.new
|
||||||
response.status = 202
|
response.status = 202
|
||||||
response.body = {}
|
response.body = {}
|
||||||
|
|
|
@ -35,8 +35,10 @@ module Fog
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
def list_stacks(options = {})
|
def list_stacks(options = {})
|
||||||
|
stacks = self.data[:stacks].values
|
||||||
|
|
||||||
Excon::Response.new(
|
Excon::Response.new(
|
||||||
:body => { 'stacks' => [] },
|
:body => { 'stacks' => stacks },
|
||||||
:status => 200
|
:status => 200
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ Shindo.tests('Fog::Orchestration[:openstack] | stack requests', ['openstack']) d
|
||||||
'links' => Array,
|
'links' => Array,
|
||||||
'id' => String,
|
'id' => String,
|
||||||
'stack_name' => String,
|
'stack_name' => String,
|
||||||
'description' => String,
|
'description' => Fog::Nullable::String,
|
||||||
'stack_status' => String,
|
'stack_status' => String,
|
||||||
'stack_status_reason' => String,
|
'stack_status_reason' => String,
|
||||||
'creation_time' => Time,
|
'creation_time' => Time,
|
||||||
|
|
Loading…
Add table
Reference in a new issue