From 16f94ed4b7f322f10c7f7e5393cc179aa3015863 Mon Sep 17 00:00:00 2001 From: Brad Sickles Date: Thu, 25 Feb 2016 08:53:18 -0500 Subject: [PATCH] Added failing aws_route test that shows diff after apply. --- .../providers/aws/resource_aws_route_test.go | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_route_test.go b/builtin/providers/aws/resource_aws_route_test.go index d4f418fee..77ae56ca3 100644 --- a/builtin/providers/aws/resource_aws_route_test.go +++ b/builtin/providers/aws/resource_aws_route_test.go @@ -32,7 +32,9 @@ func TestAccAWSRoute_basic(t *testing.T) { } resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccPreCheck(t) + }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSRouteDestroy, Steps: []resource.TestStep{ @@ -93,7 +95,9 @@ func TestAccAWSRoute_changeCidr(t *testing.T) { } resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccPreCheck(t) + }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSRouteDestroy, Steps: []resource.TestStep{ @@ -116,6 +120,44 @@ func TestAccAWSRoute_changeCidr(t *testing.T) { }) } +func TestAccAWSRoute_noopdiff(t *testing.T) { + var route ec2.Route + var routeTable ec2.RouteTable + + testCheck := func(s *terraform.State) error { + return nil + } + + testCheckChange := func(s *terraform.State) error { + return nil + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSRouteDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSRouteNoopChange, + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSRouteExists("aws_route.test", &route), + testCheck, + ), + }, + resource.TestStep{ + Config: testAccAWSRouteNoopChange, + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSRouteExists("aws_route.test", &route), + testAccCheckRouteTableExists("aws_route_table.test", &routeTable), + testCheckChange, + ), + }, + }, + }) +} + // Acceptance test if mixed inline and external routes are implemented /* func TestAccAWSRoute_mix(t *testing.T) { @@ -296,3 +338,30 @@ resource "aws_route" "bar" { gateway_id = "${aws_internet_gateway.foo.id}" } `) + +var testAccAWSRouteNoopChange = fmt.Sprint(` +resource "aws_vpc" "test" { + cidr_block = "10.10.0.0/16" +} + +resource "aws_route_table" "test" { + vpc_id = "${aws_vpc.test.id}" +} + +resource "aws_subnet" "test" { + vpc_id = "${aws_vpc.test.id}" + cidr_block = "10.10.10.0/24" +} + +resource "aws_route" "test" { + route_table_id = "${aws_route_table.test.id}" + destination_cidr_block = "0.0.0.0/0" + instance_id = "${aws_instance.nat.id}" +} + +resource "aws_instance" "nat" { + ami = "ami-9abea4fb" + instance_type = "t2.nano" + subnet_id = "${aws_subnet.test.id}" +} +`)