Adding a RandomString generator to test for db_param_group_name being too long
This commit is contained in:
parent
cc56431b97
commit
97188d6583
|
@ -2,7 +2,9 @@ package aws
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"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"
|
||||||
|
@ -151,6 +153,15 @@ func TestResourceAWSDBParameterGroupName_trailingHyphen(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestResourceAWSDBParameterGroupName_tooManyCharacters(t *testing.T) {
|
||||||
|
dbParamGroupName := RandomString(256)
|
||||||
|
_, errors := validateDbParamGroupName(dbParamGroupName, "SampleKey")
|
||||||
|
|
||||||
|
if len(errors) != 1 {
|
||||||
|
t.Fatalf("Expected the DB Parameter Group Name to trigger a validation error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func testAccCheckAWSDBParameterGroupDestroy(s *terraform.State) error {
|
func testAccCheckAWSDBParameterGroupDestroy(s *terraform.State) error {
|
||||||
conn := testAccProvider.Meta().(*AWSClient).rdsconn
|
conn := testAccProvider.Meta().(*AWSClient).rdsconn
|
||||||
|
|
||||||
|
@ -238,6 +249,16 @@ func testAccCheckAWSDBParameterGroupExists(n string, v *rds.DBParameterGroup) re
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RandomString(strlen int) string {
|
||||||
|
rand.Seed(time.Now().UTC().UnixNano())
|
||||||
|
const chars = "abcdefghijklmnopqrstuvwxyz0123456789"
|
||||||
|
result := make([]byte, strlen)
|
||||||
|
for i := 0; i < strlen; i++ {
|
||||||
|
result[i] = chars[rand.Intn(len(chars))]
|
||||||
|
}
|
||||||
|
return string(result)
|
||||||
|
}
|
||||||
|
|
||||||
const testAccAWSDBParameterGroupConfig = `
|
const testAccAWSDBParameterGroupConfig = `
|
||||||
resource "aws_db_parameter_group" "bar" {
|
resource "aws_db_parameter_group" "bar" {
|
||||||
name = "parameter-group-test-terraform"
|
name = "parameter-group-test-terraform"
|
||||||
|
|
Loading…
Reference in New Issue