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

(#9241) Add test skeleton framework

Without this patch the change set currently has no framework for testing
the Vsphere provider.  This patch doesn't actually test anything, but
does add the skeleton code to being testing mocked versions of other
code.

Particularly, we're going to take the approach of completely mocking the
@connection instance variable of the Compute instance.  This will allow
us to set expectations and return things from the underlying vmware API
library.
This commit is contained in:
Jeff McCune 2011-08-30 14:55:21 -07:00
parent 8bc5c768ec
commit 00fbdaa932
4 changed files with 39 additions and 2 deletions

View file

@ -19,7 +19,14 @@ module Fog
class Mock
def initialize(options={})
Fog::Mock.not_implemented
require 'mocha'
@vsphere_username = options[:vsphere_username]
@vsphere_password = options[:vsphere_password]
@vsphere_server = options[:vsphere_server]
@vsphere_expected_pubkey_hash = options[:vsphere_expected_pubkey_hash]
@connection = Mocha::Mock.new
# This may, or may not, be a terrible idea:
@connection.stub_everything
end
end

View file

@ -0,0 +1,10 @@
Shindo.tests('Fog::Compute[:vsphere] | current_time request', ['vsphere']) do
compute = Fog::Compute[:vsphere]
tests('is a Time object').succeeds do
pending if Fog.mock?
compute.current_time.is_a?(Time)
end
end

View file

@ -0,0 +1,16 @@
class Vsphere
module Compute
module Formats
SUMMARY = {
'id' => Integer,
'name' => String
}
end
end
end

View file

@ -52,6 +52,10 @@ if Fog.mock?
:zerigo_token => 'zerigo_token',
:dynect_customer => 'dynect_customer',
:dynect_username => 'dynect_username',
:dynect_password => 'dynect_password'
:dynect_password => 'dynect_password',
:vsphere_server => 'virtualcenter.lan',
:vsphere_username => 'apiuser',
:vsphere_password => 'apipassword',
:vsphere_expected_pubkey_hash => 'abcdef1234567890'
})
end