Skip to content

Commit

Permalink
fix test cases of rds parametergroup (#1111)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason-Zhang9309 authored May 8, 2021
1 parent 100bf6a commit ed4526a
Showing 1 changed file with 46 additions and 40 deletions.
86 changes: 46 additions & 40 deletions huaweicloud/resource_huaweicloud_rds_configuration_v3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"

Expand All @@ -13,30 +14,29 @@ import (

func TestAccRdsConfigurationV3_basic(t *testing.T) {
var config configurations.Configuration
rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(5))
updateName := fmt.Sprintf("tf-acc-test-%s-update", acctest.RandString(5))
resourceName := "huaweicloud_rds_parametergroup.pg_1"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRdsConfigV3Destroy,
Steps: []resource.TestStep{
{
Config: testAccRdsConfigV3_basic,
Config: testAccRdsConfigV3_basic(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckRdsConfigV3Exists("huaweicloud_rds_parametergroup_v3.pg_1", &config),
resource.TestCheckResourceAttr(
"huaweicloud_rds_parametergroup_v3.pg_1", "name", "pg_1"),
resource.TestCheckResourceAttr(
"huaweicloud_rds_parametergroup_v3.pg_1", "description", "description_1"),
testAccCheckRdsConfigV3Exists(resourceName, &config),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "description", "description_1"),
),
},
{
Config: testAccRdsConfigV3_update,
Config: testAccRdsConfigV3_update(updateName),
Check: resource.ComposeTestCheckFunc(
testAccCheckRdsConfigV3Exists("huaweicloud_rds_parametergroup_v3.pg_1", &config),
resource.TestCheckResourceAttr(
"huaweicloud_rds_parametergroup_v3.pg_1", "name", "pg_update"),
resource.TestCheckResourceAttr(
"huaweicloud_rds_parametergroup_v3.pg_1", "description", "description_update"),
testAccCheckRdsConfigV3Exists(resourceName, &config),
resource.TestCheckResourceAttr(resourceName, "name", updateName),
resource.TestCheckResourceAttr(resourceName, "description", "description_update"),
),
},
},
Expand All @@ -51,7 +51,7 @@ func testAccCheckRdsConfigV3Destroy(s *terraform.State) error {
}

for _, rs := range s.RootModule().Resources {
if rs.Type != "huaweicloud_rds_parametergroup_v3" {
if rs.Type != "huaweicloud_rds_parametergroup" {
continue
}

Expand Down Expand Up @@ -96,32 +96,38 @@ func testAccCheckRdsConfigV3Exists(n string, configuration *configurations.Confi
}
}

const testAccRdsConfigV3_basic = `
resource "huaweicloud_rds_parametergroup_v3" "pg_1" {
name = "pg_1"
description = "description_1"
values = {
max_connections = "10"
autocommit = "OFF"
}
datastore {
type = "mysql"
version = "5.6"
}
func testAccRdsConfigV3_basic(rName string) string {
return fmt.Sprintf(`
resource "huaweicloud_rds_parametergroup" "pg_1" {
name = "%s"
description = "description_1"
values = {
max_connections = "10"
autocommit = "OFF"
}
datastore {
type = "mysql"
version = "5.6"
}
}
`

const testAccRdsConfigV3_update = `
resource "huaweicloud_rds_parametergroup_v3" "pg_1" {
name = "pg_update"
description = "description_update"
values = {
max_connections = "10"
autocommit = "OFF"
}
datastore {
type = "mysql"
version = "5.6"
}
`, rName)
}

func testAccRdsConfigV3_update(updateName string) string {
return fmt.Sprintf(`
resource "huaweicloud_rds_parametergroup" "pg_1" {
name = "%s"
description = "description_update"
values = {
max_connections = "10"
autocommit = "OFF"
}
datastore {
type = "mysql"
version = "5.6"
}
}
`, updateName)
}
`

0 comments on commit ed4526a

Please sign in to comment.