Add test to check for failed state of the VPC Peering Connection.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
This commit is contained in:
Krzysztof Wilczynski 2016-09-26 09:17:24 +01:00
parent a58650c980
commit a2a2de5db2
No known key found for this signature in database
GPG Key ID: B89F6447B63419A6
1 changed files with 34 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"log"
"reflect"
"regexp"
"testing"
"github.com/aws/aws-sdk-go/aws"
@ -190,6 +191,21 @@ func TestAccAWSVPCPeeringConnection_options(t *testing.T) {
})
}
func TestAccAWSVPCPeeringConnection_failedState(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshIgnore: []string{"auto_accept"},
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSVpcPeeringConnectionDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccVpcPeeringConfigFailedState,
ExpectError: regexp.MustCompile(`.*Error waiting.*\(pcx-\w+\).*incorrect.*VPC-ID.*`),
},
},
})
}
func testAccCheckAWSVpcPeeringConnectionDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).ec2conn
@ -368,3 +384,21 @@ resource "aws_vpc_peering_connection" "foo" {
}
}
`
const testAccVpcPeeringConfigFailedState = `
resource "aws_vpc" "foo" {
cidr_block = "10.0.0.0/16"
tags {
Name = "TestAccAWSVPCPeeringConnection_failedState"
}
}
resource "aws_vpc" "bar" {
cidr_block = "10.0.0.0/16"
}
resource "aws_vpc_peering_connection" "foo" {
vpc_id = "${aws_vpc.foo.id}"
peer_vpc_id = "${aws_vpc.bar.id}"
}
`