Skip to content

Commit

Permalink
r/spot_instances_request: Fix failing acceptance test (SubnetId)
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Oct 25, 2017
1 parent 4e6b0a9 commit 80a2af5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions aws/resource_aws_spot_instance_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ func testAccCheckAWSSpotInstanceRequest_InstanceAttributes(
func testAccCheckAWSSpotInstanceRequest_NetworkInterfaceAttributes(
sir *ec2.SpotInstanceRequest) resource.TestCheckFunc {
return func(s *terraform.State) error {

if sir.LaunchSpecification.NetworkInterfaces == nil || len(sir.LaunchSpecification.NetworkInterfaces) != 1 {
return fmt.Errorf("Error with Spot Instance Network Interface count")
nis := sir.LaunchSpecification.NetworkInterfaces
if nis == nil || len(nis) != 1 {
return fmt.Errorf("Expected exactly 1 network interface, found %d", len(nis))
}

return nil
Expand All @@ -354,8 +354,15 @@ func testAccCheckAWSSpotInstanceRequest_NetworkInterfaceAttributes(
func testAccCheckAWSSpotInstanceRequestAttributesVPC(
sir *ec2.SpotInstanceRequest) resource.TestCheckFunc {
return func(s *terraform.State) error {
if sir.LaunchSpecification.SubnetId == nil {
return fmt.Errorf("SubnetID was not passed, but should have been for this instance to belong to a VPC")
nis := sir.LaunchSpecification.NetworkInterfaces
if nis == nil || len(nis) != 1 {
return fmt.Errorf("Expected exactly 1 network interface, found %d", len(nis))
}

ni := nis[0]

if ni.SubnetId == nil {
return fmt.Errorf("Expected SubnetId not be non-empty for %s as the instance belongs to a VPC", *sir.InstanceId)
}
return nil
}
Expand Down

0 comments on commit 80a2af5

Please sign in to comment.