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

fix test cases of rds parametergroup #1111

Merged
merged 1 commit into from
May 8, 2021
Merged
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
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)
}
`