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:
parent
8bc5c768ec
commit
00fbdaa932
4 changed files with 39 additions and 2 deletions
|
@ -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
|
||||
|
|
10
tests/compute/requests/vsphere/current_time_tests.rb
Normal file
10
tests/compute/requests/vsphere/current_time_tests.rb
Normal 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
|
16
tests/compute/requests/vsphere/helper.rb
Normal file
16
tests/compute/requests/vsphere/helper.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
class Vsphere
|
||||
|
||||
module Compute
|
||||
|
||||
module Formats
|
||||
|
||||
SUMMARY = {
|
||||
'id' => Integer,
|
||||
'name' => String
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue