Merge pull request #11826 from hashicorp/f-redshift-parameter-group-test-fixes

provider/aws: Fix redshift parameter group acctests
This commit is contained in:
Jake Champlin 2017-02-09 10:24:11 -05:00 committed by GitHub
commit 767764ff10
2 changed files with 41 additions and 33 deletions

View File

@ -3,22 +3,24 @@ package aws
import ( import (
"testing" "testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
) )
func TestAccAWSRedshiftParameterGroup_importBasic(t *testing.T) { func TestAccAWSRedshiftParameterGroup_importBasic(t *testing.T) {
resourceName := "aws_redshift_parameter_group.bar" resourceName := "aws_redshift_parameter_group.bar"
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSRedshiftParameterGroupDestroy, CheckDestroy: testAccCheckAWSRedshiftParameterGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccAWSRedshiftParameterGroupConfig, Config: testAccAWSRedshiftParameterGroupConfig(rInt),
}, },
resource.TestStep{ {
ResourceName: resourceName, ResourceName: resourceName,
ImportState: true, ImportState: true,
ImportStateVerify: true, ImportStateVerify: true,

View File

@ -7,24 +7,26 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/redshift" "github.com/aws/aws-sdk-go/service/redshift"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
func TestAccAWSRedshiftParameterGroup_withParameters(t *testing.T) { func TestAccAWSRedshiftParameterGroup_withParameters(t *testing.T) {
var v redshift.ClusterParameterGroup var v redshift.ClusterParameterGroup
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSRedshiftParameterGroupDestroy, CheckDestroy: testAccCheckAWSRedshiftParameterGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccAWSRedshiftParameterGroupConfig, Config: testAccAWSRedshiftParameterGroupConfig(rInt),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckAWSRedshiftParameterGroupExists("aws_redshift_parameter_group.bar", &v), testAccCheckAWSRedshiftParameterGroupExists("aws_redshift_parameter_group.bar", &v),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"aws_redshift_parameter_group.bar", "name", "parameter-group-test-terraform"), "aws_redshift_parameter_group.bar", "name", fmt.Sprintf("test-terraform-%d", rInt)),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"aws_redshift_parameter_group.bar", "family", "redshift-1.0"), "aws_redshift_parameter_group.bar", "family", "redshift-1.0"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
@ -49,18 +51,19 @@ func TestAccAWSRedshiftParameterGroup_withParameters(t *testing.T) {
func TestAccAWSRedshiftParameterGroup_withoutParameters(t *testing.T) { func TestAccAWSRedshiftParameterGroup_withoutParameters(t *testing.T) {
var v redshift.ClusterParameterGroup var v redshift.ClusterParameterGroup
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSRedshiftParameterGroupDestroy, CheckDestroy: testAccCheckAWSRedshiftParameterGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccAWSRedshiftParameterGroupOnlyConfig, Config: testAccAWSRedshiftParameterGroupOnlyConfig(rInt),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckAWSRedshiftParameterGroupExists("aws_redshift_parameter_group.bar", &v), testAccCheckAWSRedshiftParameterGroupExists("aws_redshift_parameter_group.bar", &v),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"aws_redshift_parameter_group.bar", "name", "parameter-group-test-terraform"), "aws_redshift_parameter_group.bar", "name", fmt.Sprintf("test-terraform-%d", rInt)),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"aws_redshift_parameter_group.bar", "family", "redshift-1.0"), "aws_redshift_parameter_group.bar", "family", "redshift-1.0"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
@ -179,28 +182,31 @@ func testAccCheckAWSRedshiftParameterGroupExists(n string, v *redshift.ClusterPa
} }
} }
const testAccAWSRedshiftParameterGroupOnlyConfig = ` func testAccAWSRedshiftParameterGroupOnlyConfig(rInt int) string {
resource "aws_redshift_parameter_group" "bar" { return fmt.Sprintf(`
name = "parameter-group-test-terraform" resource "aws_redshift_parameter_group" "bar" {
family = "redshift-1.0" name = "test-terraform-%d"
description = "Test parameter group for terraform" family = "redshift-1.0"
}` description = "Test parameter group for terraform"
}`, rInt)
const testAccAWSRedshiftParameterGroupConfig = ` }
resource "aws_redshift_parameter_group" "bar" {
name = "parameter-group-test-terraform" func testAccAWSRedshiftParameterGroupConfig(rInt int) string {
family = "redshift-1.0" return fmt.Sprintf(`
parameter { resource "aws_redshift_parameter_group" "bar" {
name = "require_ssl" name = "test-terraform-%d"
value = "true" family = "redshift-1.0"
} parameter {
parameter { name = "require_ssl"
name = "query_group" value = "true"
value = "example" }
} parameter {
parameter{ name = "query_group"
name = "enable_user_activity_logging" value = "example"
value = "true" }
} parameter{
name = "enable_user_activity_logging"
value = "true"
}
}`, rInt)
} }
`