From 29a7bef5e7d2a60317363b930b221790b1c253ad Mon Sep 17 00:00:00 2001 From: Trotter Cashion Date: Mon, 2 Jul 2012 16:53:36 -0700 Subject: [PATCH] Enable tests when mocking --- .../create_launch_configuration.rb | 3 +-- .../auto_scaling/delete_auto_scaling_group.rb | 19 ++++++++----------- .../describe_auto_scaling_instances.rb | 1 - .../auto_scaling/auto_scaling_tests.rb | 6 ++++-- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/fog/aws/requests/auto_scaling/create_launch_configuration.rb b/lib/fog/aws/requests/auto_scaling/create_launch_configuration.rb index 042c23979..75e4a618c 100644 --- a/lib/fog/aws/requests/auto_scaling/create_launch_configuration.rb +++ b/lib/fog/aws/requests/auto_scaling/create_launch_configuration.rb @@ -78,9 +78,8 @@ module Fog data[:launch_configurations][launch_configuration_name] = { 'BlockDeviceMappings' => [], 'CreatedTime' => Time.now.utc, - 'IamInstanceProfile' => nil, 'ImageId' => image_id, - 'InstanceMonitoring.Enabled' => true, + 'InstanceMonitoring' => {'Enabled' => true}, 'InstanceType' => instance_type, 'KernelId' => nil, 'KeyName' => nil, diff --git a/lib/fog/aws/requests/auto_scaling/delete_auto_scaling_group.rb b/lib/fog/aws/requests/auto_scaling/delete_auto_scaling_group.rb index 4d174c339..550958c85 100644 --- a/lib/fog/aws/requests/auto_scaling/delete_auto_scaling_group.rb +++ b/lib/fog/aws/requests/auto_scaling/delete_auto_scaling_group.rb @@ -35,20 +35,17 @@ module Fog class Mock def delete_auto_scaling_group(auto_scaling_group_name) - response = Excon::Response.new - if data[:auto_scaling_groups].delete(auto_scaling_group_name) - response.status = true - response.body = { - 'requestId' => Fog::AWS::Mock.request_id, - 'return' => true - } - response - else - raise Fog::AWS::Autoscaling::NotFound.new("The auto scaling group '#{auto_scaling_group_name}' does not exist.") + unless self.data[:auto_scaling_groups].delete(auto_scaling_group_name) + raise Fog::AWS::Autoscaling::NotFound, "The auto scaling group '#{auto_scaling_group_name}' does not exist." end + response = Excon::Response.new + response.status = 200 + response.body = { + 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } + } + response end - end end diff --git a/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_instances.rb b/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_instances.rb index 2238f2f84..d06ba77b9 100644 --- a/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_instances.rb +++ b/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_instances.rb @@ -73,7 +73,6 @@ module Fog def describe_auto_scaling_instances(options = {}) results = { 'AutoScalingInstances' => [] } data[:auto_scaling_groups].each do |asg_name, asg_data| - lc_name = data[asg_data][lc_name] asg_data['Instances'].each do |instance| results['AutoScalingInstances'] << { 'AutoScalingGroupName' => asg_name diff --git a/tests/aws/requests/auto_scaling/auto_scaling_tests.rb b/tests/aws/requests/auto_scaling/auto_scaling_tests.rb index 9eab046fa..34ec4c74a 100644 --- a/tests/aws/requests/auto_scaling/auto_scaling_tests.rb +++ b/tests/aws/requests/auto_scaling/auto_scaling_tests.rb @@ -3,8 +3,6 @@ Shindo.tests('AWS::AutoScaling | auto_scaling_tests', ['aws', 'auto_scaling']) d @lc_name = 'fog-test-lc' tests('success') do - pending if Fog.mocking? - tests("#describe_adjustment_types").formats(AWS::AutoScaling::Formats::DESCRIBE_ADJUSTMENT_TYPES) do Fog::AWS[:auto_scaling].describe_adjustment_types.body end @@ -54,15 +52,19 @@ Shindo.tests('AWS::AutoScaling | auto_scaling_tests', ['aws', 'auto_scaling']) d end tests("#describe_scaling_activities").formats(AWS::AutoScaling::Formats::DESCRIBE_SCALING_ACTIVITIES) do + pending if Fog.mocking? Fog::AWS[:auto_scaling].describe_scaling_activities().body end tests("#describe_scaling_activities").formats(AWS::AutoScaling::Formats::DESCRIBE_SCALING_ACTIVITIES) do + pending if Fog.mocking? Fog::AWS[:auto_scaling].describe_scaling_activities('ActivityIds' => '1').body end tests("#describe_scaling_activities").formats(AWS::AutoScaling::Formats::DESCRIBE_SCALING_ACTIVITIES) do + pending if Fog.mocking? Fog::AWS[:auto_scaling].describe_scaling_activities('ActivityIds' => ['1', '2']).body end tests("#describe_scaling_activities").formats(AWS::AutoScaling::Formats::DESCRIBE_SCALING_ACTIVITIES) do + pending if Fog.mocking? Fog::AWS[:auto_scaling].describe_scaling_activities('AutoScalingGroupName' => @asg_name).body end