From 409df4866d8a05293ba3d1c87aee18684a8d12a8 Mon Sep 17 00:00:00 2001 From: stack72 Date: Thu, 5 Nov 2015 10:25:01 +0000 Subject: [PATCH] Changes after the feedback from @catsby - these all made perfect sense --- .../providers/aws/resource_aws_rds_cluster.go | 5 +++ .../aws/resource_aws_rds_cluster_test.go | 40 ++++++++++++++++--- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/builtin/providers/aws/resource_aws_rds_cluster.go b/builtin/providers/aws/resource_aws_rds_cluster.go index ece9b686f..6dac39f0e 100644 --- a/builtin/providers/aws/resource_aws_rds_cluster.go +++ b/builtin/providers/aws/resource_aws_rds_cluster.go @@ -127,12 +127,17 @@ func resourceAwsRDSCluster() *schema.Resource { "preferred_backup_window": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, }, "preferred_maintenance_window": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, StateFunc: func(val interface{}) string { + if val == nil { + return "" + } return strings.ToLower(val.(string)) }, }, diff --git a/builtin/providers/aws/resource_aws_rds_cluster_test.go b/builtin/providers/aws/resource_aws_rds_cluster_test.go index a9eed687e..d0d285362 100644 --- a/builtin/providers/aws/resource_aws_rds_cluster_test.go +++ b/builtin/providers/aws/resource_aws_rds_cluster_test.go @@ -20,6 +20,27 @@ func TestAccAWSRDSCluster_basic(t *testing.T) { ri := rand.New(rand.NewSource(time.Now().UnixNano())).Int() config := fmt.Sprintf(testAccAWSClusterConfig, ri) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSClusterDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: config, + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSClusterExists("aws_rds_cluster.default", &v), + ), + }, + }, + }) +} + +func TestAccAWSRDSCluster_backups(t *testing.T) { + var v rds.DBCluster + + ri := rand.New(rand.NewSource(time.Now().UnixNano())).Int() + config := fmt.Sprintf(testAccAWSClusterConfig_backups, ri) + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -41,12 +62,12 @@ func TestAccAWSRDSCluster_basic(t *testing.T) { }) } -func TestAccAWSRDSCluster_update(t *testing.T) { +func TestAccAWSRDSCluster_backupsUpdate(t *testing.T) { var v rds.DBCluster ri := rand.New(rand.NewSource(time.Now().UnixNano())).Int() - preConfig := fmt.Sprintf(testAccAWSClusterConfig, ri) - postConfig := fmt.Sprintf(testAccAWSClusterConfig_update, ri) + preConfig := fmt.Sprintf(testAccAWSClusterConfig_backups, ri) + postConfig := fmt.Sprintf(testAccAWSClusterConfig_backupsUpdate, ri) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -147,8 +168,16 @@ func testAccCheckAWSClusterExists(n string, v *rds.DBCluster) resource.TestCheck } } -// Add some random to the name, to avoid collision var testAccAWSClusterConfig = ` +resource "aws_rds_cluster" "default" { + cluster_identifier = "tf-aurora-cluster-%d" + availability_zones = ["us-west-2a","us-west-2b","us-west-2c"] + database_name = "mydb" + master_username = "foo" + master_password = "mustbeeightcharaters" +}` + +var testAccAWSClusterConfig_backups = ` resource "aws_rds_cluster" "default" { cluster_identifier = "tf-aurora-cluster-%d" availability_zones = ["us-west-2a","us-west-2b","us-west-2c"] @@ -160,8 +189,7 @@ resource "aws_rds_cluster" "default" { preferred_maintenance_window = "tue:04:00-tue:04:30" }` -// Add some random to the name, to avoid collision -var testAccAWSClusterConfig_update = ` +var testAccAWSClusterConfig_backupsUpdate = ` resource "aws_rds_cluster" "default" { cluster_identifier = "tf-aurora-cluster-%d" availability_zones = ["us-west-2a","us-west-2b","us-west-2c"]