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

Tests for previous commit

This commit is contained in:
Thomas Kadauke 2013-06-04 14:34:55 +02:00 committed by Dan Prince
parent ecef54c8bc
commit 9457089347
3 changed files with 79 additions and 2 deletions

View file

@ -17,6 +17,8 @@ class OpenStack < Fog::Bin
Fog::Volume::OpenStack
when :metering
Fog::Metering::OpenStack
when :orchestration
Fog::Orchestration::OpenStack
else
raise ArgumentError, "Unrecognized service: #{key}"
end
@ -46,6 +48,9 @@ class OpenStack < Fog::Bin
when :metering
Fog::Logger.warning("OpenStack[:metering] is not recommended, use Metering[:openstack] for portability")
Fog::Metering.new(:provider => 'OpenStack')
when :orchestration
Fog::Logger.warning("OpenStack[:orchestration] is not recommended, use Orchestration[:openstack] for portability")
Fog::Orchestration.new(:provider => 'OpenStack')
else
raise ArgumentError, "Unrecognized service: #{key.inspect}"
end

View file

@ -22,11 +22,53 @@ module Fog
request :list_stacks
class Mock
attr_reader :auth_token
attr_reader :auth_token_expiration
attr_reader :current_user
attr_reader :current_tenant
def initialize(options={})
Fog::Mock.not_implemented
def self.data
@data ||= {}
end
def self.reset
@data = nil
end
def initialize(options={})
@openstack_username = options[:openstack_username]
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
@current_tenant = options[:openstack_tenant]
@auth_token = Fog::Mock.random_base64(64)
@auth_token_expiration = (Time.now.utc + 86400).iso8601
management_url = URI.parse(options[:openstack_auth_url])
management_url.port = 8774
management_url.path = '/v1'
@openstack_management_url = management_url.to_s
identity_public_endpoint = URI.parse(options[:openstack_auth_url])
identity_public_endpoint.port = 5000
@openstack_identity_public_endpoint = identity_public_endpoint.to_s
end
def data
self.class.data["#{@openstack_username}-#{@current_tenant}"]
end
def reset_data
self.class.data.delete("#{@openstack_username}-#{@current_tenant}")
end
def credentials
{ :provider => 'openstack',
:openstack_auth_url => @openstack_auth_uri.to_s,
:openstack_auth_token => @auth_token,
:openstack_management_url => @openstack_management_url,
:openstack_identity_endpoint => @openstack_identity_public_endpoint }
end
end
class Real

View file

@ -0,0 +1,30 @@
Shindo.tests('Fog::Orchestration[:openstack] | stack requests', ['openstack']) do
@stack_format = {
'links' => Array,
'id' => String,
'stack_name' => String,
'description' => String,
'stack_status' => String,
'stack_status_reason' => String,
'creation_time' => Time,
'updated_time' => Time
}
tests('success') do
tests('#create_stack("teststack")').formats({}) do
Fog::Orchestration[:openstack].create_stack("teststack").body
end
tests('#list_stacks').formats({'stacks' => [@stack_format]}) do
Fog::Orchestration[:openstack].list_stacks.body
end
tests('#update_stack("teststack")').formats({}) do
Fog::Orchestration[:openstack].update_stack("teststack").body
end
tests('#delete_stack("teststack", "id")').formats({}) do
Fog::Orchestration[:openstack].delete_stack("teststack", "id").body
end
end
end