@@ -8,32 +8,30 @@ import (
88
99var testDataTcaplusTablesName = "data.tencentcloud_tcaplus_tables.id_test"
1010
11- func TestAccTencentCloudDataTcaplusTables (t * testing.T ) {
11+ func TestAccTencentCloudTcaplusTablesData (t * testing.T ) {
1212 t .Parallel ()
1313 resource .Test (t , resource.TestCase {
1414 PreCheck : func () { testAccPreCheck (t ) },
1515 Providers : testAccProviders ,
1616 CheckDestroy : testAccCheckTcaplusTableDestroy ,
1717 Steps : []resource.TestStep {
1818 {
19- Config : testAccTencentCloudDataTcaplusTablesBaic ,
19+ Config : testAccTencentCloudDataTcaplusTablesBasic ,
2020 Check : resource .ComposeAggregateTestCheckFunc (
21- testAccCheckTcaplusTableExists ("tencentcloud_tcaplus_table.test_table" ),
2221 resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "cluster_id" ),
23- resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "table_id " ),
24- resource .TestCheckResourceAttr (testDataTcaplusTablesName , "list.#" , "1 " ),
22+ resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "table_name " ),
23+ resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "list.#" ),
2524 resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "list.0.tablegroup_id" ),
2625 resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "list.0.table_id" ),
27- resource .TestCheckResourceAttr (testDataTcaplusTablesName , "list.0.table_name" , "tb_online_guagua " ),
26+ resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "list.0.table_name" ),
2827 resource .TestCheckResourceAttr (testDataTcaplusTablesName , "list.0.table_type" , "GENERIC" ),
29- resource .TestCheckResourceAttr (testDataTcaplusTablesName , "list.0.description" , "test " ),
28+ resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "list.0.description" ),
3029 resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "list.0.idl_id" ),
3130 resource .TestCheckResourceAttr (testDataTcaplusTablesName , "list.0.table_idl_type" , "PROTO" ),
32- resource .TestCheckResourceAttr (testDataTcaplusTablesName , "list.0.reserved_read_cu" , "1000 " ),
33- resource .TestCheckResourceAttr (testDataTcaplusTablesName , "list.0.reserved_write_cu" , "20 " ),
34- resource .TestCheckResourceAttr (testDataTcaplusTablesName , "list.0.reserved_volume" , "1 " ),
31+ resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "list.0.reserved_read_cu" ),
32+ resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "list.0.reserved_write_cu" ),
33+ resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "list.0.reserved_volume" ),
3534 resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "list.0.create_time" ),
36- resource .TestCheckResourceAttr (testDataTcaplusTablesName , "list.0.error" , "" ),
3735 resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "list.0.status" ),
3836 resource .TestCheckResourceAttrSet (testDataTcaplusTablesName , "list.0.table_size" ),
3937 ),
@@ -42,79 +40,9 @@ func TestAccTencentCloudDataTcaplusTables(t *testing.T) {
4240 })
4341}
4442
45- const testAccTencentCloudDataTcaplusTablesBaic = `
46- variable "availability_zone" {
47- default = "ap-guangzhou-3"
48- }
49-
50- data "tencentcloud_vpc_subnets" "vpc" {
51- is_default = true
52- availability_zone = var.availability_zone
53- }
54-
55- resource "tencentcloud_tcaplus_cluster" "test_cluster" {
56- idl_type = "PROTO"
57- cluster_name = "tf_tcaplus_data_guagua"
58- vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
59- subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id
60- password = "1qaA2k1wgvfa3ZZZ"
61- old_password_expire_last = 3600
62- }
63- resource "tencentcloud_tcaplus_idl" "test_idl" {
64- cluster_id = tencentcloud_tcaplus_cluster.test_cluster.id
65- tablegroup_id = tencentcloud_tcaplus_tablegroup.test_group.id
66- file_name = "tf_idl_test_guagua"
67- file_type = "PROTO"
68- file_ext_type = "proto"
69- file_content = <<EOF
70- syntax = "proto2";
71- package myTcaplusTable;
72- import "tcaplusservice.optionv1.proto";
73- message tb_online_guagua {
74- option(tcaplusservice.tcaplus_primary_key) = "uin,name,region";
75- required int64 uin = 1;
76- required string name = 2;
77- required int32 region = 3;
78- required int32 gamesvrid = 4;
79- optional int32 logintime = 5 [default = 1];
80- repeated int64 lockid = 6 [packed = true];
81- optional bool is_available = 7 [default = false];
82- optional pay_info pay = 8;
83- }
84-
85- message pay_info {
86- required int64 pay_id = 1;
87- optional uint64 total_money = 2;
88- optional uint64 pay_times = 3;
89- optional pay_auth_info auth = 4;
90- message pay_auth_info {
91- required string pay_keys = 1;
92- optional int64 update_time = 2;
93- }
94- }
95- EOF
96- }
97-
98- resource "tencentcloud_tcaplus_table" "test_table" {
99- cluster_id = tencentcloud_tcaplus_cluster.test_cluster.id
100- tablegroup_id = tencentcloud_tcaplus_tablegroup.test_group.id
101- table_name = "tb_online_guagua"
102- table_type = "GENERIC"
103- description = "test"
104- idl_id = tencentcloud_tcaplus_idl.test_idl.id
105- table_idl_type = "PROTO"
106- reserved_read_cu = 1000
107- reserved_write_cu = 20
108- reserved_volume = 1
109- }
110-
111- resource "tencentcloud_tcaplus_tablegroup" "test_group" {
112- cluster_id = tencentcloud_tcaplus_cluster.test_cluster.id
113- tablegroup_name = "tf_test_group_name_guagua"
114- }
115-
43+ const testAccTencentCloudDataTcaplusTablesBasic = defaultTcaPlusData + `
11644data "tencentcloud_tcaplus_tables" "id_test" {
117- cluster_id = tencentcloud_tcaplus_cluster.test_cluster.id
118- table_id = tencentcloud_tcaplus_table.test_table.id
45+ cluster_id = local.tcaplus_id
46+ table_name = local.tcaplus_table
11947}
12048`
0 commit comments