mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[tests] make unimplemented mock tests pending
This commit is contained in:
parent
2da3af865f
commit
7620662c87
14 changed files with 80 additions and 40 deletions
|
|
@ -117,9 +117,11 @@ module Fog
|
|||
request :undeploy
|
||||
|
||||
class Mock
|
||||
def request(options)
|
||||
raise "Not implemented"
|
||||
|
||||
def initialize(options={})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Real
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ Shindo.tests('AWS::CloudWatch | metric requests', ['aws', 'cloudwatch']) do
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
tests("#get_metric_statistics").formats(@metrics_statistic_format) do
|
||||
pending if Fog.mocking?
|
||||
instanceId = 'i-420c352f'
|
||||
AWS[:cloud_watch].get_metric_statistics({'Statistics' => ['Minimum','Maximum','Sum','SampleCount','Average'], 'StartTime' => (Time.now-600).iso8601, 'EndTime' => Time.now.iso8601, 'Period' => 60, 'MetricName' => 'DiskReadBytes', 'Namespace' => 'AWS/EC2', 'Dimensions' => [{'Name' => 'InstanceId', 'Value' => instanceId}]}).body
|
||||
end
|
||||
|
|
|
|||
|
|
@ -36,14 +36,17 @@ Shindo.tests('AWS::CloudWatch | metric requests', ['aws', 'cloudwatch']) do
|
|||
}
|
||||
|
||||
tests("#list_metrics").formats(@metrics_list_format) do
|
||||
pending if Fog.mocking?
|
||||
AWS[:cloud_watch].list_metrics.body
|
||||
end
|
||||
|
||||
tests("#dimension_filtered_list_metrics").formats(@dimension_filtered_metrics_list_format) do
|
||||
pending if Fog.mocking?
|
||||
AWS[:cloud_watch].list_metrics('Dimensions' => [{'Name' => 'InstanceId', 'Value' => @instanceId}]).body
|
||||
end
|
||||
|
||||
tests("#metric_name_filtered_list_metrics").returns(true) do
|
||||
pending if Fog.mocking?
|
||||
metricName = "CPUUtilization"
|
||||
AWS[:cloud_watch].list_metrics('MetricName' => metricName).body['ListMetricsResult']['Metrics'].all? do |metric|
|
||||
metric['MetricName'] == metricName
|
||||
|
|
@ -51,6 +54,7 @@ Shindo.tests('AWS::CloudWatch | metric requests', ['aws', 'cloudwatch']) do
|
|||
end
|
||||
|
||||
tests("#namespace_filtered_list_metrics").returns(true) do
|
||||
pending if Fog.mocking?
|
||||
namespace = "AWS/EC2"
|
||||
AWS[:cloud_watch].list_metrics('Namespace' => namespace).body['ListMetricsResult']['Metrics'].all? do |metric|
|
||||
metric['Namespace'] == namespace
|
||||
|
|
|
|||
|
|
@ -1,24 +1,27 @@
|
|||
Shindo.tests('AWS::CloudWatch | metric requests', ['aws', 'cloudwatch']) do
|
||||
tests('success') do
|
||||
namespace = 'Custom/Test'
|
||||
|
||||
namespace = 'Custom/Test'
|
||||
@puts_format = {'ResponseMetadata' => {'RequestId' => String}}
|
||||
|
||||
tests('#puts_value').formats(@puts_format) do
|
||||
pending if Fog.mocking?
|
||||
AWS[:cloud_watch].put_metric_data(namespace, [{'MetricName' => 'RequestTest', 'Unit' => 'None', 'Value' => 1}]).body
|
||||
end
|
||||
|
||||
tests('#puts_statistics_set').succeeds do
|
||||
pending if Fog.mocking?
|
||||
AWS[:cloud_watch].put_metric_data(namespace, [{'MetricName' => 'RequestTest', 'Unit' => 'None', 'StatisticValues' => {'Minimum' => 0, 'Maximum' => 9, 'Sum' => 45, 'SampleCount' => 10, 'Average' => 4.5}}]).body
|
||||
end
|
||||
|
||||
tests('#puts with dimensions').succeeds do
|
||||
pending if Fog.mocking?
|
||||
dimensions = [{}]
|
||||
|
||||
AWS[:cloud_watch].put_metric_data(namespace, [{'MetricName' => 'RequestTest', 'Unit' => 'None', 'Value' => 1, 'Dimensions' => dimensions}]).body
|
||||
end
|
||||
|
||||
tests('#puts more than one').succeeds do
|
||||
pending if Fog.mocking?
|
||||
datapoints = (0...3).collect do |i|
|
||||
dp = {'MetricName' => "#{i}RequestTest", 'Unit' => 'None', 'Value' => i}
|
||||
if i%2==0
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ Shindo.tests('AWS::ELB | listener_tests', ['aws', 'elb']) do
|
|||
{'Protocol' => 'HTTP', 'LoadBalancerPort' => 80, 'InstancePort' => 80}
|
||||
]
|
||||
response = AWS[:elb].create_load_balancer_listeners(@load_balancer_id, listeners).body
|
||||
puts response.inspect
|
||||
response
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -44,18 +44,22 @@ Shindo.tests('AWS::SES | topic lifecycle tests', ['aws', 'sns']) do
|
|||
})
|
||||
|
||||
tests("#list_subscriptions").formats(list_subscriptions_format) do
|
||||
pending if Fog.mocking?
|
||||
AWS[:sns].list_subscriptions.body
|
||||
end
|
||||
|
||||
tests("#list_subscriptions_by_topic('#{@topic_arn}')").formats(list_subscriptions_format) do
|
||||
pending if Fog.mocking?
|
||||
body = AWS[:sns].list_subscriptions_by_topic(@topic_arn).body
|
||||
end
|
||||
|
||||
tests("#publish('#{@topic_arn}', 'message')").formats(AWS::SNS::Formats::BASIC.merge('MessageId' => String)) do
|
||||
pending if Fog.mocking?
|
||||
body = AWS[:sns].publish(@topic_arn, 'message').body
|
||||
end
|
||||
|
||||
tests("#receive_message('#{@queue_url}')...").returns('message') do
|
||||
pending if Fog.mocking?
|
||||
message = nil
|
||||
Fog.wait_for do
|
||||
message = AWS[:sqs].receive_message(@queue_url).body['Message'].first
|
||||
|
|
@ -64,6 +68,7 @@ Shindo.tests('AWS::SES | topic lifecycle tests', ['aws', 'sns']) do
|
|||
end
|
||||
|
||||
tests("#unsubscribe('#{@subscription_arn}')").formats(AWS::SNS::Formats::BASIC) do
|
||||
pending if Fog.mocking?
|
||||
AWS[:sns].unsubscribe(@subscription_arn).body
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,25 @@
|
|||
class Vcloud
|
||||
module Compute
|
||||
module TestSupport
|
||||
def self.template
|
||||
template_name = ENV['VCLOUD_TEMPLATE']
|
||||
raise "Specify VApp template name in VCLOUD_TEMPLATE env var" unless template_name
|
||||
template_res = Vcloud.catalogs.item_by_name template_name
|
||||
raise "URI Not found for specified template - check template name" unless template_res
|
||||
template_res.href
|
||||
|
||||
if Fog.mocking?
|
||||
def self.template
|
||||
'mock_template'
|
||||
end
|
||||
else
|
||||
def self.template
|
||||
template_name = ENV['VCLOUD_TEMPLATE']
|
||||
raise "Specify VApp template name in VCLOUD_TEMPLATE env var" unless template_name
|
||||
template_res = Vcloud.catalogs.item_by_name template_name
|
||||
raise "URI Not found for specified template - check template name" unless template_res
|
||||
template_res.href
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
module Formats
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ Shindo.tests('Fog::Compute[:aws] | address requests', ['aws']) do
|
|||
|
||||
@server = Fog::Compute[:aws].servers.create
|
||||
@server.wait_for { ready? }
|
||||
@ip_address = @server.ip_address
|
||||
@ip_address = @server.public_ip_address
|
||||
|
||||
tests('success') do
|
||||
|
||||
|
|
|
|||
|
|
@ -59,18 +59,23 @@ EOF
|
|||
end
|
||||
end
|
||||
|
||||
Vcloud[:compute].stub!(:request).and_return(MockDiskResponse.new)
|
||||
unless Fog.mocking?
|
||||
Vcloud[:compute].stub!(:request).and_return(MockDiskResponse.new)
|
||||
end
|
||||
|
||||
tests("Call to generate config returns string").returns(true) do
|
||||
pending if Fog.mocking?
|
||||
Vcloud[:compute].generate_configure_vm_disks_request('http://blah', disk_hash).kind_of? String
|
||||
end
|
||||
|
||||
tests("Call to generate config with no changes returns input data").returns(true) do
|
||||
pending if Fog.mocking?
|
||||
Nokogiri::XML(Vcloud[:compute].generate_configure_vm_disks_request('http://blah', disk_hash)).to_s ==
|
||||
Nokogiri::XML(MockDiskResponse.new.body).to_s
|
||||
end
|
||||
|
||||
tests("Call to generate config with no disks removes disk").returns(true) do
|
||||
pending if Fog.mocking?
|
||||
xml = Vcloud[:compute].generate_configure_vm_disks_request('http://blah', [])
|
||||
ng = Nokogiri::XML(xml)
|
||||
# Should have 2 controllers, but no disks.
|
||||
|
|
@ -79,6 +84,7 @@ EOF
|
|||
end
|
||||
|
||||
tests("Call to generate config adding a disk").returns(['4096', true, true]) do
|
||||
pending if Fog.mocking?
|
||||
disks = disk_hash
|
||||
disks << {
|
||||
:"rasd:AddressOnParent"=>"1",
|
||||
|
|
@ -102,6 +108,7 @@ EOF
|
|||
]
|
||||
end
|
||||
|
||||
|
||||
Vcloud[:compute].unstub!(:request)
|
||||
unless Fog.mocking?
|
||||
Vcloud[:compute].unstub!(:request)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,10 +16,6 @@ Shindo.tests('test_helper', 'meta') do
|
|||
formats_kernel({:a => {:b => :c}}, {:a => {:b => Symbol}})
|
||||
end
|
||||
|
||||
test('when format of nested hash with anonymous key and value') do
|
||||
formats_kernel({:a => {:b => :c}}, {:a => {Symbol => Symbol}})
|
||||
end
|
||||
|
||||
test('when format of an array') do
|
||||
formats_kernel([{:a => :b}], [{:a => Symbol}])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ if Fog.mock?
|
|||
:new_servers_username => 'new_servers_username',
|
||||
:ninefold_compute_key => 'ninefold_compute_key',
|
||||
:ninefold_compute_secret => 'ninefold_compute_secret',
|
||||
:ninefold_storage_secret => 'ninefold_storage_secret',
|
||||
:ninefold_storage_token => 'ninefold_storage_token',
|
||||
# :public_key_path => '~/.ssh/id_rsa.pub',
|
||||
# :private_key_path => '~/.ssh/id_rsa',
|
||||
:rackspace_api_key => 'rackspace_api_key',
|
||||
|
|
@ -39,6 +41,9 @@ if Fog.mock?
|
|||
:slicehost_password => 'slicehost_password',
|
||||
:storm_on_demand_username => 'storm_on_demand_username',
|
||||
:storm_on_demand_password => 'storm_on_demand_password',
|
||||
:vcloud_host => 'vcloud_host',
|
||||
:vcloud_password => 'vcloud_password',
|
||||
:vcloud_username => 'vcloud_username',
|
||||
:voxel_api_key => 'voxel_api_key',
|
||||
:voxel_api_secret => 'voxel_api_secret',
|
||||
:zerigo_email => 'zerigo_email',
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ if storage_providers.keys.include? :ninefold
|
|||
Shindo.tests("Storage[:ninefold] | nested directories", [provider]) do
|
||||
ninefold = Fog::Storage[:ninefold]
|
||||
tests("update a file").succeeds do
|
||||
pending if Fog.mocking?
|
||||
dir = ninefold.directories.create(:key => 'updatefiletests')
|
||||
f = dir.files.create(:key => 'lorem.txt', :body => lorem_file)
|
||||
f.body = "xxxxxx"
|
||||
|
|
|
|||
|
|
@ -4,18 +4,22 @@ if storage_providers.keys.include? :ninefold
|
|||
Shindo.tests("Storage[:ninefold] | nested directories", [provider]) do
|
||||
ninefold = Fog::Storage[:ninefold]
|
||||
tests("create a directory with a / character").succeeds do
|
||||
pending if Fog.mocking?
|
||||
ninefold.directories.create(:key => 'sub/path')
|
||||
end
|
||||
|
||||
tests("List of top directory returns sub dir").returns(1) do
|
||||
pending if Fog.mocking?
|
||||
ninefold.directories.get('sub').directories.count
|
||||
end
|
||||
|
||||
tests("create a directory in a sub dir").returns('sub/path/newdir/') do
|
||||
pending if Fog.mocking?
|
||||
ninefold.directories.get('sub/path').directories.create(:key => 'newdir').identity
|
||||
end
|
||||
|
||||
tests("Recursively destroy parent dir").succeeds do
|
||||
pending if Fog.mocking?
|
||||
ninefold.directories.get('sub').destroy(:recursive => true)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,30 +1,32 @@
|
|||
Shindo.tests('Fog::Storage[:rackspace] | large object requests', [:rackspace]) do
|
||||
|
||||
@directory = Fog::Storage[:rackspace].directories.create(:key => 'foglargeobjecttests')
|
||||
unless Fog.mocking?
|
||||
@directory = Fog::Storage[:rackspace].directories.create(:key => 'foglargeobjecttests')
|
||||
end
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#put_object('#{@directory.identity}', 'fog_large_object/1', ('x' * 6 * 1024 * 1024))").succeeds do
|
||||
tests("#put_object('foglargeobjecttests', 'fog_large_object/1', ('x' * 6 * 1024 * 1024))").succeeds do
|
||||
pending if Fog.mocking?
|
||||
Fog::Storage[:rackspace].put_object(@directory.identity, 'fog_large_object/1', ('x' * 6 * 1024 * 1024))
|
||||
end
|
||||
|
||||
tests("#put_object('#{@directory.identity}', 'fog_large_object/2', ('x' * 4 * 1024 * 1024))").succeeds do
|
||||
tests("#put_object('foglargeobjecttests', 'fog_large_object/2', ('x' * 4 * 1024 * 1024))").succeeds do
|
||||
pending if Fog.mocking?
|
||||
Fog::Storage[:rackspace].put_object(@directory.identity, 'fog_large_object/2', ('x' * 4 * 1024 * 1024))
|
||||
end
|
||||
|
||||
tests("#put_object_manifest('#{@directory.identity}', 'fog_large_object')").succeeds do
|
||||
tests("#put_object_manifest('foglargeobjecttests', 'fog_large_object')").succeeds do
|
||||
pending if Fog.mocking?
|
||||
Fog::Storage[:rackspace].put_object_manifest(@directory.identity, 'fog_large_object')
|
||||
end
|
||||
|
||||
tests("#get_object('#{@directory.identity}', 'fog_large_object').body").succeeds do
|
||||
tests("#get_object('foglargeobjecttests', 'fog_large_object').body").succeeds do
|
||||
pending if Fog.mocking?
|
||||
Fog::Storage[:rackspace].get_object(@directory.identity, 'fog_large_object').body == ('x' * 10 * 1024 * 1024)
|
||||
end
|
||||
|
||||
if !Fog.mocking?
|
||||
unless Fog.mocking?
|
||||
['fog_large_object', 'fog_large_object/1', 'fog_large_object/2'].each do |key|
|
||||
@directory.files.new(:key => key).destroy
|
||||
end
|
||||
|
|
@ -38,6 +40,8 @@ Shindo.tests('Fog::Storage[:rackspace] | large object requests', [:rackspace]) d
|
|||
|
||||
end
|
||||
|
||||
@directory.destroy
|
||||
unless Fog.mocking?
|
||||
@directory.destroy
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue