Seed test value names and tidy up whitespace

This commit is contained in:
Matt Dainty 2017-02-18 18:53:32 +00:00
parent 4678fa4121
commit e141df0cd0
No known key found for this signature in database
GPG Key ID: D57145DF9EBCC9BA
6 changed files with 28 additions and 18 deletions

View File

@ -3,19 +3,22 @@ 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 TestAccAWSCloudwatchLogDestinationPolicy_importBasic(t *testing.T) { func TestAccAWSCloudwatchLogDestinationPolicy_importBasic(t *testing.T) {
resourceName := "aws_cloudwatch_log_destination_policy.test" resourceName := "aws_cloudwatch_log_destination_policy.test"
rstring := acctest.RandString(5)
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCloudwatchLogDestinationPolicyDestroy, CheckDestroy: testAccCheckAWSCloudwatchLogDestinationPolicyDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSCloudwatchLogDestinationPolicyConfig(), Config: testAccAWSCloudwatchLogDestinationPolicyConfig(rstring),
}, },
resource.TestStep{ resource.TestStep{

View File

@ -3,19 +3,22 @@ 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 TestAccAWSCloudwatchLogDestination_importBasic(t *testing.T) { func TestAccAWSCloudwatchLogDestination_importBasic(t *testing.T) {
resourceName := "aws_cloudwatch_log_destination.test" resourceName := "aws_cloudwatch_log_destination.test"
rstring := acctest.RandString(5)
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCloudwatchLogDestinationDestroy, CheckDestroy: testAccCheckAWSCloudwatchLogDestinationDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSCloudwatchLogDestinationConfig(), Config: testAccAWSCloudwatchLogDestinationConfig(rstring),
}, },
resource.TestStep{ resource.TestStep{

View File

@ -16,7 +16,6 @@ func resourceAwsCloudWatchLogDestination() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
Create: resourceAwsCloudWatchLogDestinationPut, Create: resourceAwsCloudWatchLogDestinationPut,
Update: resourceAwsCloudWatchLogDestinationPut, Update: resourceAwsCloudWatchLogDestinationPut,
Read: resourceAwsCloudWatchLogDestinationRead, Read: resourceAwsCloudWatchLogDestinationRead,
Delete: resourceAwsCloudWatchLogDestinationDelete, Delete: resourceAwsCloudWatchLogDestinationDelete,

View File

@ -13,7 +13,6 @@ func resourceAwsCloudWatchLogDestinationPolicy() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
Create: resourceAwsCloudWatchLogDestinationPolicyPut, Create: resourceAwsCloudWatchLogDestinationPolicyPut,
Update: resourceAwsCloudWatchLogDestinationPolicyPut, Update: resourceAwsCloudWatchLogDestinationPolicyPut,
Read: resourceAwsCloudWatchLogDestinationPolicyRead, Read: resourceAwsCloudWatchLogDestinationPolicyRead,
Delete: resourceAwsCloudWatchLogDestinationPolicyDelete, Delete: resourceAwsCloudWatchLogDestinationPolicyDelete,

View File

@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs" "github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"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"
) )
@ -12,13 +13,15 @@ import (
func TestAccAWSCloudwatchLogDestinationPolicy_basic(t *testing.T) { func TestAccAWSCloudwatchLogDestinationPolicy_basic(t *testing.T) {
var destination cloudwatchlogs.Destination var destination cloudwatchlogs.Destination
rstring := acctest.RandString(5)
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCloudwatchLogDestinationPolicyDestroy, CheckDestroy: testAccCheckAWSCloudwatchLogDestinationPolicyDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
{ {
Config: testAccAWSCloudwatchLogDestinationPolicyConfig(), Config: testAccAWSCloudwatchLogDestinationPolicyConfig(rstring),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckAWSCloudwatchLogDestinationPolicyExists("aws_cloudwatch_log_destination_policy.test", &destination), testAccCheckAWSCloudwatchLogDestinationPolicyExists("aws_cloudwatch_log_destination_policy.test", &destination),
), ),
@ -70,10 +73,10 @@ func testAccCheckAWSCloudwatchLogDestinationPolicyExists(n string, d *cloudwatch
} }
} }
func testAccAWSCloudwatchLogDestinationPolicyConfig() string { func testAccAWSCloudwatchLogDestinationPolicyConfig(rstring string) string {
return fmt.Sprintf(` return fmt.Sprintf(`
resource "aws_kinesis_stream" "test" { resource "aws_kinesis_stream" "test" {
name = "RootAccess" name = "RootAccess_%s"
shard_count = 1 shard_count = 1
} }
@ -97,7 +100,7 @@ data "aws_iam_policy_document" "role" {
} }
resource "aws_iam_role" "test" { resource "aws_iam_role" "test" {
name = "CWLtoKinesisRole" name = "CWLtoKinesisRole_%s"
assume_role_policy = "${data.aws_iam_policy_document.role.json}" assume_role_policy = "${data.aws_iam_policy_document.role.json}"
} }
@ -123,13 +126,13 @@ data "aws_iam_policy_document" "policy" {
} }
resource "aws_iam_role_policy" "test" { resource "aws_iam_role_policy" "test" {
name = "Permissions-Policy-For-CWL" name = "Permissions-Policy-For-CWL_%s"
role = "${aws_iam_role.test.id}" role = "${aws_iam_role.test.id}"
policy = "${data.aws_iam_policy_document.policy.json}" policy = "${data.aws_iam_policy_document.policy.json}"
} }
resource "aws_cloudwatch_log_destination" "test" { resource "aws_cloudwatch_log_destination" "test" {
name = "testDestination" name = "testDestination_%s"
target_arn = "${aws_kinesis_stream.test.arn}" target_arn = "${aws_kinesis_stream.test.arn}"
role_arn = "${aws_iam_role.test.arn}" role_arn = "${aws_iam_role.test.arn}"
depends_on = ["aws_iam_role_policy.test"] depends_on = ["aws_iam_role_policy.test"]
@ -157,5 +160,5 @@ resource "aws_cloudwatch_log_destination_policy" "test" {
destination_name = "${aws_cloudwatch_log_destination.test.name}" destination_name = "${aws_cloudwatch_log_destination.test.name}"
access_policy = "${data.aws_iam_policy_document.access.json}" access_policy = "${data.aws_iam_policy_document.access.json}"
} }
`) `, rstring, rstring, rstring, rstring)
} }

View File

@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs" "github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"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"
) )
@ -12,13 +13,15 @@ import (
func TestAccAWSCloudwatchLogDestination_basic(t *testing.T) { func TestAccAWSCloudwatchLogDestination_basic(t *testing.T) {
var destination cloudwatchlogs.Destination var destination cloudwatchlogs.Destination
rstring := acctest.RandString(5)
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCloudwatchLogDestinationDestroy, CheckDestroy: testAccCheckAWSCloudwatchLogDestinationDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
{ {
Config: testAccAWSCloudwatchLogDestinationConfig(), Config: testAccAWSCloudwatchLogDestinationConfig(rstring),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckAWSCloudwatchLogDestinationExists("aws_cloudwatch_log_destination.test", &destination), testAccCheckAWSCloudwatchLogDestinationExists("aws_cloudwatch_log_destination.test", &destination),
), ),
@ -70,10 +73,10 @@ func testAccCheckAWSCloudwatchLogDestinationExists(n string, d *cloudwatchlogs.D
} }
} }
func testAccAWSCloudwatchLogDestinationConfig() string { func testAccAWSCloudwatchLogDestinationConfig(rstring string) string {
return fmt.Sprintf(` return fmt.Sprintf(`
resource "aws_kinesis_stream" "test" { resource "aws_kinesis_stream" "test" {
name = "RootAccess" name = "RootAccess_%s"
shard_count = 1 shard_count = 1
} }
@ -97,7 +100,7 @@ data "aws_iam_policy_document" "role" {
} }
resource "aws_iam_role" "test" { resource "aws_iam_role" "test" {
name = "CWLtoKinesisRole" name = "CWLtoKinesisRole_%s"
assume_role_policy = "${data.aws_iam_policy_document.role.json}" assume_role_policy = "${data.aws_iam_policy_document.role.json}"
} }
@ -123,13 +126,13 @@ data "aws_iam_policy_document" "policy" {
} }
resource "aws_iam_role_policy" "test" { resource "aws_iam_role_policy" "test" {
name = "Permissions-Policy-For-CWL" name = "Permissions-Policy-For-CWL_%s"
role = "${aws_iam_role.test.id}" role = "${aws_iam_role.test.id}"
policy = "${data.aws_iam_policy_document.policy.json}" policy = "${data.aws_iam_policy_document.policy.json}"
} }
resource "aws_cloudwatch_log_destination" "test" { resource "aws_cloudwatch_log_destination" "test" {
name = "testDestination" name = "testDestination_%s"
target_arn = "${aws_kinesis_stream.test.arn}" target_arn = "${aws_kinesis_stream.test.arn}"
role_arn = "${aws_iam_role.test.arn}" role_arn = "${aws_iam_role.test.arn}"
depends_on = ["aws_iam_role_policy.test"] depends_on = ["aws_iam_role_policy.test"]
@ -157,5 +160,5 @@ resource "aws_cloudwatch_log_destination_policy" "test" {
destination_name = "${aws_cloudwatch_log_destination.test.name}" destination_name = "${aws_cloudwatch_log_destination.test.name}"
access_policy = "${data.aws_iam_policy_document.access.json}" access_policy = "${data.aws_iam_policy_document.access.json}"
} }
`) `, rstring, rstring, rstring, rstring)
} }