mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
mock power_on
This commit is contained in:
parent
cee42dce00
commit
e7aa0e83c1
2 changed files with 46 additions and 2 deletions
|
@ -8,8 +8,17 @@ module Fog
|
|||
end
|
||||
|
||||
class Mock
|
||||
def power_on(on_uri)
|
||||
Fog::Mock.not_implemented
|
||||
def power_on(vapp_uri)
|
||||
vapp, vdc = vapp_and_vdc_from_vapp_uri(vapp_uri)
|
||||
|
||||
if vapp
|
||||
vapp[:status] = 4
|
||||
|
||||
builder = Builder::XmlMarkup.new
|
||||
mock_it 200, builder.Task(xmlns)
|
||||
else
|
||||
mock_error 200, "401 Unauthorized"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
35
spec/vcloud/terremark/ecloud/requests/power_on_spec.rb
Normal file
35
spec/vcloud/terremark/ecloud/requests/power_on_spec.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
|
||||
|
||||
if Fog.mocking?
|
||||
describe Fog::Vcloud, :type => :mock_tmrk_ecloud_request do
|
||||
subject { @vcloud }
|
||||
|
||||
it { should respond_to :power_on }
|
||||
|
||||
describe :power_on, :type => :vcloud_request do
|
||||
context "with a valid vapp uri" do
|
||||
let(:vm_data) { @vcloud.mock_data[:organizations].first[:vdcs].first[:vms].first }
|
||||
before { vm_data[:status] = 2; @power_on = @vcloud.power_on(@vcloud.vdcs.first.servers.first.href) }
|
||||
subject { @power_on }
|
||||
|
||||
it_should_behave_like "all responses"
|
||||
#it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.network+xml" }
|
||||
|
||||
specify { vm_data[:status].should == 4 }
|
||||
|
||||
describe :body do
|
||||
subject { @power_on.body }
|
||||
|
||||
it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
|
||||
end
|
||||
end
|
||||
|
||||
context "with a vapp uri that doesn't exist" do
|
||||
subject { lambda { @vcloud.get_network(URI.parse('https://www.fakey.com/api/v0.8/vapp/9999')) } }
|
||||
it_should_behave_like "a request for a resource that doesn't exist"
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
end
|
||||
|
Loading…
Add table
Reference in a new issue