Skip to content

Commit

Permalink
azurerm_spring_cloud_app_mysql_association - fix tests (#26859)
Browse files Browse the repository at this point in the history
* `azurerm_spring_cloud_app_mysql_association` - fix tests

* update validation

* update update test config
  • Loading branch information
ms-henglu authored Aug 1, 2024
1 parent 4572ca8 commit 1712e1b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2017-12-01/servers"
flexibleServers "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2022-01-01/servers"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/springcloud/migration"
Expand Down Expand Up @@ -66,10 +67,13 @@ func resourceSpringCloudAppMysqlAssociation() *pluginsdk.Resource {
},

"mysql_server_id": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: servers.ValidateServerID,
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.Any(
servers.ValidateServerID,
flexibleServers.ValidateFlexibleServerID,
),
},

"database_name": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ func (r SpringCloudAppMysqlAssociationResource) basic(data acceptance.TestData)
resource "azurerm_spring_cloud_app_mysql_association" "test" {
name = "acctestscamb-%d"
spring_cloud_app_id = azurerm_spring_cloud_app.test.id
mysql_server_id = azurerm_mysql_server.test.id
database_name = azurerm_mysql_database.test.name
username = azurerm_mysql_server.test.administrator_login
password = azurerm_mysql_server.test.administrator_login_password
mysql_server_id = azurerm_mysql_flexible_server.test.id
database_name = azurerm_mysql_flexible_database.test.name
username = azurerm_mysql_flexible_server.test.administrator_login
password = azurerm_mysql_flexible_server.test.administrator_password
}
`, r.template(data), data.RandomInteger)
}
Expand All @@ -118,21 +118,21 @@ func (r SpringCloudAppMysqlAssociationResource) update(data acceptance.TestData)
return fmt.Sprintf(`
%s
resource "azurerm_mysql_database" "updated" {
name = "acctest-db2-%d"
resource "azurerm_mysql_flexible_database" "updated" {
name = "acctestdb2_%d"
resource_group_name = azurerm_resource_group.test.name
server_name = azurerm_mysql_server.test.name
server_name = azurerm_mysql_flexible_server.test.name
charset = "utf8"
collation = "utf8_unicode_ci"
}
resource "azurerm_spring_cloud_app_mysql_association" "test" {
name = "acctestscamb-%d"
spring_cloud_app_id = azurerm_spring_cloud_app.test.id
mysql_server_id = azurerm_mysql_server.test.id
database_name = azurerm_mysql_database.updated.name
username = azurerm_mysql_server.test.administrator_login
password = azurerm_mysql_server.test.administrator_login_password
mysql_server_id = azurerm_mysql_flexible_server.test.id
database_name = azurerm_mysql_flexible_database.updated.name
username = azurerm_mysql_flexible_server.test.administrator_login
password = azurerm_mysql_flexible_server.test.administrator_password
}
`, r.template(data), data.RandomInteger, data.RandomInteger)
}
Expand Down Expand Up @@ -160,23 +160,20 @@ resource "azurerm_spring_cloud_app" "test" {
service_name = azurerm_spring_cloud_service.test.name
}
resource "azurerm_mysql_server" "test" {
name = "acctestmysqlsvr-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku_name = "GP_Gen5_2"
administrator_login = "acctestun"
administrator_login_password = "H@Sh1CoR3!"
ssl_enforcement_enabled = true
ssl_minimal_tls_version_enforced = "TLS1_1"
storage_mb = 51200
version = "5.7"
resource "azurerm_mysql_flexible_server" "test" {
name = "acctest-fs-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
zone = "1"
}
resource "azurerm_mysql_database" "test" {
name = "acctest-db-%d"
resource "azurerm_mysql_flexible_database" "test" {
name = "acctestdb_%d"
resource_group_name = azurerm_resource_group.test.name
server_name = azurerm_mysql_server.test.name
server_name = azurerm_mysql_flexible_server.test.name
charset = "utf8"
collation = "utf8_unicode_ci"
}
Expand Down

0 comments on commit 1712e1b

Please sign in to comment.