Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 18 additions & 0 deletions tencentcloud/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,10 @@ locals {

// SQLServer
const defaultSQLServerName = "keep-preset_sqlserver"
const defaultPubSQLServerName = "keep-publish-instance"
const defaultSubSQLServerName = "keep-subscribe-instance"
const defaultSQLServerDB = "keep_sqlserver_db"
const defaultSQLServerPubSubDB = "keep_pubsub_db"
const defaultSQLServerAccount = "keep_sqlserver_account"

const CommonPresetSQLServer = `
Expand Down Expand Up @@ -308,6 +311,21 @@ locals {
}
`

const CommonPubSubSQLServer = `
data "tencentcloud_sqlserver_instances" "pub_sqlserver" {
name = "` + defaultPubSQLServerName + `"
}
data "tencentcloud_sqlserver_instances" "sub_sqlserver" {
name = "` + defaultSubSQLServerName + `"
}

locals {
pub_sqlserver_id = data.tencentcloud_sqlserver_instances.pub_sqlserver.instance_list.0.id
sub_sqlserver_id = data.tencentcloud_sqlserver_instances.sub_sqlserver.instance_list.0.id
sqlserver_pubsub_db = "` + defaultSQLServerPubSubDB + `"
}
`

const instanceCommonTestCase = defaultInstanceVariable + `
resource "tencentcloud_instance" "default" {
instance_name = var.instance_name
Expand Down
95 changes: 10 additions & 85 deletions tencentcloud/resource_tc_sqlserver_publish_subscribe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
)

func TestAccTencentCloudSqlserverPublishSubscribeResource(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand All @@ -26,7 +25,6 @@ func TestAccTencentCloudSqlserverPublishSubscribeResource(t *testing.T) {
resource.TestCheckResourceAttr("tencentcloud_sqlserver_publish_subscribe.example", "publish_subscribe_name", "example"),
resource.TestCheckResourceAttr("tencentcloud_sqlserver_publish_subscribe.example", "database_tuples.#", "1"),
),
Destroy: false,
},
{
Config: testAccSqlserverPublishSubscribe_basic_update_name,
Expand Down Expand Up @@ -97,98 +95,25 @@ func testAccCheckSqlserverPublishSubscribeExists(n string) resource.TestCheckFun
}
}

const testAccSqlserverPublishSubscribe_basic = defaultVpcSubnets + defaultSecurityGroupData + `
resource "tencentcloud_sqlserver_instance" "publish_instance" {
name = "tf_sqlserver_publish_instance"
availability_zone = var.default_az
charge_type = "POSTPAID_BY_HOUR"
vpc_id = local.vpc_id
subnet_id = local.subnet_id
project_id = 0
memory = 2
storage = 10
maintenance_week_set = [1,2,3]
maintenance_start_time = "09:00"
maintenance_time_span = 3
security_groups = [local.sg_id]
}

resource "tencentcloud_sqlserver_instance" "subscribe_instance" {
name = "tf_sqlserver_subscribe_instance"
availability_zone = var.default_az
charge_type = "POSTPAID_BY_HOUR"
vpc_id = local.vpc_id
subnet_id = local.subnet_id
project_id = 0
memory = 2
storage = 10
maintenance_week_set = [1,2,3]
maintenance_start_time = "09:00"
maintenance_time_span = 3
security_groups = [local.sg_id]
}

resource "tencentcloud_sqlserver_db" "test_publish_subscribe" {
instance_id = tencentcloud_sqlserver_instance.publish_instance.id
name = "test111"
charset = "Chinese_PRC_BIN"
remark = "testACC-remark"
}
const testAccSqlserverPublishSubscribe_basic = CommonPubSubSQLServer + `

resource "tencentcloud_sqlserver_publish_subscribe" "example" {
publish_instance_id = tencentcloud_sqlserver_instance.publish_instance.id
subscribe_instance_id = tencentcloud_sqlserver_instance.subscribe_instance.id
publish_instance_id = local.pub_sqlserver_id
subscribe_instance_id = local.sub_sqlserver_id
publish_subscribe_name = "example"
delete_subscribe_db = false
delete_subscribe_db = true
database_tuples {
publish_database = tencentcloud_sqlserver_db.test_publish_subscribe.name
publish_database = local.sqlserver_pubsub_db
}
}`

const testAccSqlserverPublishSubscribe_basic_update_name = defaultVpcSubnets + defaultSecurityGroupData + `
resource "tencentcloud_sqlserver_instance" "publish_instance" {
name = "tf_sqlserver_publish_instance"
availability_zone = var.default_az
charge_type = "POSTPAID_BY_HOUR"
vpc_id = local.vpc_id
subnet_id = local.subnet_id
project_id = 0
memory = 2
storage = 10
maintenance_week_set = [1,2,3]
maintenance_start_time = "09:00"
maintenance_time_span = 3
security_groups = [local.sg_id]
}

resource "tencentcloud_sqlserver_instance" "subscribe_instance" {
name = "tf_sqlserver_subscribe_instance"
availability_zone = var.default_az
charge_type = "POSTPAID_BY_HOUR"
vpc_id = local.vpc_id
subnet_id = local.subnet_id
project_id = 0
memory = 2
storage = 10
maintenance_week_set = [1,2,3]
maintenance_start_time = "09:00"
maintenance_time_span = 3
security_groups = [local.sg_id]
}

resource "tencentcloud_sqlserver_db" "test_publish_subscribe" {
instance_id = tencentcloud_sqlserver_instance.publish_instance.id
name = "test111"
charset = "Chinese_PRC_BIN"
remark = "testACC-remark"
}

const testAccSqlserverPublishSubscribe_basic_update_name = CommonPubSubSQLServer + `
resource "tencentcloud_sqlserver_publish_subscribe" "example" {
publish_instance_id = tencentcloud_sqlserver_instance.publish_instance.id
subscribe_instance_id = tencentcloud_sqlserver_instance.subscribe_instance.id
publish_instance_id = local.pub_sqlserver_id
subscribe_instance_id = local.sub_sqlserver_id
publish_subscribe_name = "example1"
delete_subscribe_db = false
delete_subscribe_db = true
database_tuples {
publish_database = tencentcloud_sqlserver_db.test_publish_subscribe.name
publish_database = local.sqlserver_pubsub_db
}
}`