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

fix tests in real mode

This commit is contained in:
Eugene Howe 2016-10-07 13:15:04 -04:00
parent 4e2220d1cd
commit fba07bb064
4 changed files with 15 additions and 4 deletions

View file

@ -14,6 +14,10 @@ module Fog
class Mock class Mock
def modify_mount_target_security_groups(id, security_groups) def modify_mount_target_security_groups(id, security_groups)
if security_groups.nil? || security_groups.empty?
raise Fog::AWS::EFS::Error.new("Must provide at least one security group.")
end
response = Excon::Response.new response = Excon::Response.new
unless self.data[:mount_targets][id] unless self.data[:mount_targets][id]

View file

@ -5,9 +5,11 @@ Shindo.tests("AWS::EFS | mount target", ["aws", "efs"]) do
if Fog.mocking? if Fog.mocking?
vpc = Fog::Compute[:aws].vpcs.create(:cidr_block => "10.0.0.0/16") vpc = Fog::Compute[:aws].vpcs.create(:cidr_block => "10.0.0.0/16")
subnet = Fog::Compute[:aws].subnets.create(:vpc_id => vpc.id, :cidr_block => "10.0.1.0/24") subnet = Fog::Compute[:aws].subnets.create(:vpc_id => vpc.id, :cidr_block => "10.0.1.0/24")
default_security_group = Fog::Compute[:aws].security_groups.detect { |sg| sg.description == 'default group' }
else else
vpc = Fog::Compute[:aws].vpcs.first vpc = Fog::Compute[:aws].vpcs.first
subnet = vpc.subnets.first subnet = vpc.subnets.first
default_security_group = Fog::Compute[:aws].security_groups.detect { |sg| sg.description == 'default VPC security group' }
end end
security_group = Fog::Compute[:aws].security_groups.create( security_group = Fog::Compute[:aws].security_groups.create(
@ -19,19 +21,18 @@ Shindo.tests("AWS::EFS | mount target", ["aws", "efs"]) do
mount_target_params = { mount_target_params = {
:file_system_id => @file_system.identity, :file_system_id => @file_system.identity,
:subnet_id => subnet.identity, :subnet_id => subnet.identity,
:security_groups => [security_group.group_id],
} }
model_tests(Fog::AWS[:efs].mount_targets, mount_target_params, true) do model_tests(Fog::AWS[:efs].mount_targets, mount_target_params, true) do
@instance.wait_for { ready? } @instance.wait_for { ready? }
tests("#security_groups") do tests("#security_groups") do
returns([security_group.group_id]) { @instance.security_groups } returns([default_security_group.group_id]) { @instance.security_groups }
end end
tests("#security_groups=") do tests("#security_groups=") do
@instance.security_groups = [] @instance.security_groups = [security_group.group_id]
returns([]) { @instance.security_groups } returns([security_group.group_id]) { @instance.security_groups }
end end
end end

View file

@ -24,5 +24,7 @@ Shindo.tests("AWS::EFS | mount targets", ["aws", "efs"]) do
collection_tests(Fog::AWS[:efs].mount_targets(:file_system_id => @file_system.identity), mount_target_params, true) collection_tests(Fog::AWS[:efs].mount_targets(:file_system_id => @file_system.identity), mount_target_params, true)
@file_system.wait_for { number_of_mount_targets == 0 }
@file_system.destroy @file_system.destroy
security_group.destroy
end end

View file

@ -85,6 +85,10 @@ Shindo.tests('AWS::EFS | file systems', ['aws', 'efs']) do
result result
end end
raises(Fog::AWS::EFS::Error, 'Must provide at least one security group.') do
Fog::AWS[:efs].modify_mount_target_security_groups(mount_target_id, [])
end
tests("#modify_mount_target_security_groups(#{mount_target_id}, [#{security_group.group_id}])") do tests("#modify_mount_target_security_groups(#{mount_target_id}, [#{security_group.group_id}])") do
returns(204) do returns(204) do
Fog::AWS[:efs].modify_mount_target_security_groups(mount_target_id, [security_group.group_id]).status Fog::AWS[:efs].modify_mount_target_security_groups(mount_target_id, [security_group.group_id]).status