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
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
unless self.data[:mount_targets][id]

View file

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

View file

@ -85,6 +85,10 @@ Shindo.tests('AWS::EFS | file systems', ['aws', 'efs']) do
result
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
returns(204) do
Fog::AWS[:efs].modify_mount_target_security_groups(mount_target_id, [security_group.group_id]).status