Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup randomString() #10478

Merged
merged 1 commit into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Cleanup randomString()
  • Loading branch information
jukie committed Oct 11, 2019
commit 2e1ec47b8972a6bf334108879bb059b43a9e35ae
12 changes: 0 additions & 12 deletions aws/resource_aws_db_parameter_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package aws
import (
"fmt"
"log"
"math/rand"
"regexp"
"strings"
"testing"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
Expand Down Expand Up @@ -621,16 +619,6 @@ func testAccCheckAWSDBParameterGroupExists(n string, v *rds.DBParameterGroup) re
}
}

func randomString(strlen int) string {
rand.Seed(time.Now().UTC().UnixNano())
const chars = "abcdefghijklmnopqrstuvwxyz"
result := make([]byte, strlen)
for i := 0; i < strlen; i++ {
result[i] = chars[rand.Intn(len(chars))]
}
return string(result)
}

func testAccAWSDBParameterGroupConfig(n string) string {
return fmt.Sprintf(`
resource "aws_db_parameter_group" "bar" {
Expand Down
42 changes: 21 additions & 21 deletions aws/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package aws

import (
"fmt"
"github.com/aws/aws-sdk-go/service/cognitoidentity"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"regexp"
"strings"
"testing"

"github.com/aws/aws-sdk-go/service/cognitoidentity"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

)

func TestValidateTypeStringNullableBoolean(t *testing.T) {
Expand Down Expand Up @@ -1474,7 +1474,7 @@ func TestValidateNeptuneEventSubscriptionName(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(256),
Value: acctest.RandStringFromCharSet(256, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand Down Expand Up @@ -1504,7 +1504,7 @@ func TestValidateNeptuneEventSubscriptionNamePrefix(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(254),
Value: acctest.RandStringFromCharSet(254, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand Down Expand Up @@ -1534,7 +1534,7 @@ func TestValidateDbSubnetGroupName(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(300),
Value: acctest.RandStringFromCharSet(300, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand Down Expand Up @@ -1566,7 +1566,7 @@ func TestValidateNeptuneSubnetGroupName(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(300),
Value: acctest.RandStringFromCharSet(300, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand Down Expand Up @@ -1594,7 +1594,7 @@ func TestValidateDbSubnetGroupNamePrefix(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(230),
Value: acctest.RandStringFromCharSet(230, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand Down Expand Up @@ -1622,7 +1622,7 @@ func TestValidateNeptuneSubnetGroupNamePrefix(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(230),
Value: acctest.RandStringFromCharSet(230, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand Down Expand Up @@ -1658,7 +1658,7 @@ func TestValidateDbOptionGroupName(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(256),
Value: acctest.RandStringFromCharSet(256, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand Down Expand Up @@ -1690,7 +1690,7 @@ func TestValidateDbOptionGroupNamePrefix(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(230),
Value: acctest.RandStringFromCharSet(230, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand Down Expand Up @@ -1734,7 +1734,7 @@ func TestValidateDbParamGroupName(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(256),
Value: acctest.RandStringFromCharSet(256, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand Down Expand Up @@ -2451,7 +2451,7 @@ func TestResourceAWSElastiCacheReplicationGroupAuthTokenValidation(t *testing.T)
ErrCount: 1,
},
{
Value: randomString(129),
Value: acctest.RandStringFromCharSet(129, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand Down Expand Up @@ -2664,7 +2664,7 @@ func TestValidateNeptuneParamGroupName(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(256),
Value: acctest.RandStringFromCharSet(256, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand Down Expand Up @@ -2704,7 +2704,7 @@ func TestValidateNeptuneParamGroupNamePrefix(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(256),
Value: acctest.RandStringFromCharSet(256, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand Down Expand Up @@ -2732,7 +2732,7 @@ func TestValidateCloudFrontPublicKeyName(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(129),
Value: acctest.RandStringFromCharSet(129, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand Down Expand Up @@ -2760,7 +2760,7 @@ func TestValidateCloudFrontPublicKeyNamePrefix(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(128),
Value: acctest.RandStringFromCharSet(128, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand Down Expand Up @@ -2827,7 +2827,7 @@ func TestValidateLbTargetGroupName(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(33),
Value: acctest.RandStringFromCharSet(33, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand All @@ -2853,7 +2853,7 @@ func TestValidateLbTargetGroupNamePrefix(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(32),
Value: acctest.RandStringFromCharSet(32, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand All @@ -2879,7 +2879,7 @@ func TestValidateSecretManagerSecretName(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(513),
Value: acctest.RandStringFromCharSet(513, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand All @@ -2905,7 +2905,7 @@ func TestValidateSecretManagerSecretNamePrefix(t *testing.T) {
ErrCount: 1,
},
{
Value: randomString(512),
Value: acctest.RandStringFromCharSet(512, acctest.CharSetAlpha),
ErrCount: 1,
},
}
Expand All @@ -2931,7 +2931,7 @@ func TestValidateRoute53ResolverName(t *testing.T) {
ErrCount: 0,
},
{
Value: randomString(65),
Value: acctest.RandStringFromCharSet(65, acctest.CharSetAlpha),
ErrCount: 1,
},
{
Expand Down