add randomness to gateway and efs file system tests
This commit is contained in:
parent
da7ef1bb76
commit
5662b7e60f
|
@ -3,19 +3,20 @@ package aws
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccAWSCustomerGateway_importBasic(t *testing.T) {
|
||||
resourceName := "aws_customer_gateway.foo"
|
||||
|
||||
randInt := acctest.RandInt()
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccCustomerGatewayConfig,
|
||||
Config: testAccCustomerGatewayConfig(randInt),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
|
|
|
@ -3,11 +3,13 @@ package aws
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccAWSEFSFileSystem_importBasic(t *testing.T) {
|
||||
resourceName := "aws_efs_file_system.foo-with-tags"
|
||||
rInt := acctest.RandInt()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -15,7 +17,7 @@ func TestAccAWSEFSFileSystem_importBasic(t *testing.T) {
|
|||
CheckDestroy: testAccCheckEfsFileSystemDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAWSEFSFileSystemConfigWithTags,
|
||||
Config: testAccAWSEFSFileSystemConfigWithTags(rInt),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
|
|
|
@ -10,12 +10,14 @@ import (
|
|||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSCustomerGateway_basic(t *testing.T) {
|
||||
var gateway ec2.CustomerGateway
|
||||
randInt := acctest.RandInt()
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
IDRefreshName: "aws_customer_gateway.foo",
|
||||
|
@ -23,19 +25,19 @@ func TestAccAWSCustomerGateway_basic(t *testing.T) {
|
|||
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCustomerGatewayConfig,
|
||||
Config: testAccCustomerGatewayConfig(randInt),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||
),
|
||||
},
|
||||
{
|
||||
Config: testAccCustomerGatewayConfigUpdateTags,
|
||||
Config: testAccCustomerGatewayConfigUpdateTags(randInt),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||
),
|
||||
},
|
||||
{
|
||||
Config: testAccCustomerGatewayConfigForceReplace,
|
||||
Config: testAccCustomerGatewayConfigForceReplace(randInt),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||
),
|
||||
|
@ -46,6 +48,7 @@ func TestAccAWSCustomerGateway_basic(t *testing.T) {
|
|||
|
||||
func TestAccAWSCustomerGateway_similarAlreadyExists(t *testing.T) {
|
||||
var gateway ec2.CustomerGateway
|
||||
randInt := acctest.RandInt()
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
IDRefreshName: "aws_customer_gateway.foo",
|
||||
|
@ -53,13 +56,13 @@ func TestAccAWSCustomerGateway_similarAlreadyExists(t *testing.T) {
|
|||
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCustomerGatewayConfig,
|
||||
Config: testAccCustomerGatewayConfig(randInt),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||
),
|
||||
},
|
||||
{
|
||||
Config: testAccCustomerGatewayConfigIdentical,
|
||||
Config: testAccCustomerGatewayConfigIdentical(randInt),
|
||||
ExpectError: regexp.MustCompile("An existing customer gateway"),
|
||||
},
|
||||
},
|
||||
|
@ -68,13 +71,14 @@ func TestAccAWSCustomerGateway_similarAlreadyExists(t *testing.T) {
|
|||
|
||||
func TestAccAWSCustomerGateway_disappears(t *testing.T) {
|
||||
var gateway ec2.CustomerGateway
|
||||
randInt := acctest.RandInt()
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCustomerGatewayConfig,
|
||||
Config: testAccCustomerGatewayConfig(randInt),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||
testAccAWSCustomerGatewayDisappears(&gateway),
|
||||
|
@ -190,59 +194,67 @@ func testAccCheckCustomerGateway(gatewayResource string, cgw *ec2.CustomerGatewa
|
|||
}
|
||||
}
|
||||
|
||||
const testAccCustomerGatewayConfig = `
|
||||
resource "aws_customer_gateway" "foo" {
|
||||
bgp_asn = 65000
|
||||
ip_address = "172.0.0.1"
|
||||
type = "ipsec.1"
|
||||
tags {
|
||||
Name = "foo-gateway"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const testAccCustomerGatewayConfigIdentical = `
|
||||
resource "aws_customer_gateway" "foo" {
|
||||
bgp_asn = 65000
|
||||
ip_address = "172.0.0.1"
|
||||
type = "ipsec.1"
|
||||
tags {
|
||||
Name = "foo-gateway"
|
||||
func testAccCustomerGatewayConfig(randInt int) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "aws_customer_gateway" "foo" {
|
||||
bgp_asn = 65000
|
||||
ip_address = "172.0.0.1"
|
||||
type = "ipsec.1"
|
||||
tags {
|
||||
Name = "foo-gateway-%d"
|
||||
}
|
||||
}
|
||||
`, randInt)
|
||||
}
|
||||
|
||||
resource "aws_customer_gateway" "identical" {
|
||||
bgp_asn = 65000
|
||||
ip_address = "172.0.0.1"
|
||||
type = "ipsec.1"
|
||||
tags {
|
||||
Name = "foo-gateway-identical"
|
||||
}
|
||||
func testAccCustomerGatewayConfigIdentical(randInt int) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "aws_customer_gateway" "foo" {
|
||||
bgp_asn = 65000
|
||||
ip_address = "172.0.0.1"
|
||||
type = "ipsec.1"
|
||||
tags {
|
||||
Name = "foo-gateway-%d"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_customer_gateway" "identical" {
|
||||
bgp_asn = 65000
|
||||
ip_address = "172.0.0.1"
|
||||
type = "ipsec.1"
|
||||
tags {
|
||||
Name = "foo-gateway-identical-%d"
|
||||
}
|
||||
}
|
||||
`, randInt, randInt)
|
||||
}
|
||||
`
|
||||
|
||||
// Add the Another: "tag" tag.
|
||||
const testAccCustomerGatewayConfigUpdateTags = `
|
||||
resource "aws_customer_gateway" "foo" {
|
||||
bgp_asn = 65000
|
||||
ip_address = "172.0.0.1"
|
||||
type = "ipsec.1"
|
||||
tags {
|
||||
Name = "foo-gateway"
|
||||
Another = "tag"
|
||||
}
|
||||
func testAccCustomerGatewayConfigUpdateTags(randInt int) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "aws_customer_gateway" "foo" {
|
||||
bgp_asn = 65000
|
||||
ip_address = "172.0.0.1"
|
||||
type = "ipsec.1"
|
||||
tags {
|
||||
Name = "foo-gateway-%d"
|
||||
Another = "tag-%d"
|
||||
}
|
||||
}
|
||||
`, randInt, randInt)
|
||||
}
|
||||
`
|
||||
|
||||
// Change the ip_address.
|
||||
const testAccCustomerGatewayConfigForceReplace = `
|
||||
resource "aws_customer_gateway" "foo" {
|
||||
bgp_asn = 65000
|
||||
ip_address = "172.10.10.1"
|
||||
type = "ipsec.1"
|
||||
tags {
|
||||
Name = "foo-gateway"
|
||||
Another = "tag"
|
||||
func testAccCustomerGatewayConfigForceReplace(randInt int) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "aws_customer_gateway" "foo" {
|
||||
bgp_asn = 65000
|
||||
ip_address = "172.10.10.1"
|
||||
type = "ipsec.1"
|
||||
tags {
|
||||
Name = "foo-gateway-%d"
|
||||
Another = "tag-%d"
|
||||
}
|
||||
}
|
||||
`, randInt, randInt)
|
||||
}
|
||||
`
|
||||
|
|
|
@ -82,6 +82,7 @@ func TestResourceAWSEFSFileSystem_hasEmptyFileSystems(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
||||
rInt := acctest.RandInt()
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
@ -104,7 +105,7 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
|||
),
|
||||
},
|
||||
{
|
||||
Config: testAccAWSEFSFileSystemConfigWithTags,
|
||||
Config: testAccAWSEFSFileSystemConfigWithTags(rInt),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckEfsFileSystem(
|
||||
"aws_efs_file_system.foo-with-tags",
|
||||
|
@ -116,7 +117,7 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
|||
testAccCheckEfsFileSystemTags(
|
||||
"aws_efs_file_system.foo-with-tags",
|
||||
map[string]string{
|
||||
"Name": "foo-efs",
|
||||
"Name": fmt.Sprintf("foo-efs-%d", rInt),
|
||||
"Another": "tag",
|
||||
},
|
||||
),
|
||||
|
@ -143,13 +144,14 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAccAWSEFSFileSystem_pagedTags(t *testing.T) {
|
||||
rInt := acctest.RandInt()
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckEfsFileSystemDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccAWSEFSFileSystemConfigPagedTags,
|
||||
Config: testAccAWSEFSFileSystemConfigPagedTags(rInt),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_efs_file_system.foo",
|
||||
|
@ -312,34 +314,38 @@ resource "aws_efs_file_system" "foo" {
|
|||
}
|
||||
`
|
||||
|
||||
const testAccAWSEFSFileSystemConfigPagedTags = `
|
||||
resource "aws_efs_file_system" "foo" {
|
||||
creation_token = "radeksimko"
|
||||
tags {
|
||||
Name = "foo-efs"
|
||||
Another = "tag"
|
||||
Test = "yes"
|
||||
User = "root"
|
||||
Page = "1"
|
||||
Environment = "prod"
|
||||
CostCenter = "terraform"
|
||||
AcceptanceTest = "PagedTags"
|
||||
CreationToken = "radek"
|
||||
PerfMode = "max"
|
||||
Region = "us-west-2"
|
||||
func testAccAWSEFSFileSystemConfigPagedTags(rInt int) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "aws_efs_file_system" "foo" {
|
||||
creation_token = "radeksimko"
|
||||
tags {
|
||||
Name = "foo-efs-%d"
|
||||
Another = "tag"
|
||||
Test = "yes"
|
||||
User = "root"
|
||||
Page = "1"
|
||||
Environment = "prod"
|
||||
CostCenter = "terraform"
|
||||
AcceptanceTest = "PagedTags"
|
||||
CreationToken = "radek"
|
||||
PerfMode = "max"
|
||||
Region = "us-west-2"
|
||||
}
|
||||
}
|
||||
`, rInt)
|
||||
}
|
||||
`
|
||||
|
||||
const testAccAWSEFSFileSystemConfigWithTags = `
|
||||
resource "aws_efs_file_system" "foo-with-tags" {
|
||||
creation_token = "yada_yada"
|
||||
tags {
|
||||
Name = "foo-efs"
|
||||
Another = "tag"
|
||||
func testAccAWSEFSFileSystemConfigWithTags(rInt int) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "aws_efs_file_system" "foo-with-tags" {
|
||||
creation_token = "yada_yada"
|
||||
tags {
|
||||
Name = "foo-efs-%d"
|
||||
Another = "tag"
|
||||
}
|
||||
}
|
||||
`, rInt)
|
||||
}
|
||||
`
|
||||
|
||||
const testAccAWSEFSFileSystemConfigWithPerformanceMode = `
|
||||
resource "aws_efs_file_system" "foo-with-performance-mode" {
|
||||
|
|
Loading…
Reference in New Issue