From 6eb6d19384d9eb8227bbd53b5dff90e5a9eda3f6 Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Wed, 20 Aug 2014 11:26:26 -0700 Subject: [PATCH] providers/aws: vpc dns settings tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cc/ @deoxxa see diff for how to add tests – quite straight forward. Normally, I would like to add a check to ensure that the attribute was updated remotely (by seeing what it's value with AWS is) but I don't think we have that value returned. --- CHANGELOG.md | 2 ++ .../providers/aws/resource_aws_vpc_test.go | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b00e84378..ab73ad7cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ IMPROVEMENTS: attributes. * providers/aws: Security group rules can be updated without a destroy/create. + * providers/aws: You can enable and disable dns settings for VPCs + [GH-172] BUG FIXES: diff --git a/builtin/providers/aws/resource_aws_vpc_test.go b/builtin/providers/aws/resource_aws_vpc_test.go index 57de1cc71..853cbe916 100644 --- a/builtin/providers/aws/resource_aws_vpc_test.go +++ b/builtin/providers/aws/resource_aws_vpc_test.go @@ -30,6 +30,35 @@ func TestAccVpc(t *testing.T) { }) } +func TestAccVpcUpdate(t *testing.T) { + var vpc ec2.VPC + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckVpcDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccVpcConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckVpcExists("aws_vpc.foo", &vpc), + testAccCheckVpcCidr(&vpc, "10.1.0.0/16"), + resource.TestCheckResourceAttr( + "aws_vpc.foo", "cidr_block", "10.1.0.0/16"), + ), + }, + resource.TestStep{ + Config: testAccVpcConfigUpdate, + Check: resource.ComposeTestCheckFunc( + testAccCheckVpcExists("aws_vpc.foo", &vpc), + resource.TestCheckResourceAttr( + "aws_vpc.foo", "enable_dns_hostnames", "true"), + ), + }, + }, + }) +} + func testAccCheckVpcDestroy(s *terraform.State) error { conn := testAccProvider.ec2conn @@ -102,3 +131,10 @@ resource "aws_vpc" "foo" { cidr_block = "10.1.0.0/16" } ` + +const testAccVpcConfigUpdate = ` +resource "aws_vpc" "foo" { + cidr_block = "10.1.0.0/16" + enable_dns_hostnames = true +} +`