@@ -13,20 +13,19 @@ func TestAccDataSourceRedisCloudProDatabase_basic(t *testing.T) {
1313
1414 testAccRequiresEnvVar (t , "EXECUTE_TESTS" )
1515
16- name := acctest .RandomWithPrefix (testResourcePrefix )
17- password := acctest .RandString (20 )
18- testCloudAccountName := os .Getenv ("AWS_TEST_CLOUD_ACCOUNT_NAME" )
19-
2016 const dataSourceById = "data.rediscloud_database.example-by-id"
2117 const dataSourceByName = "data.rediscloud_database.example-by-name"
18+ password := acctest .RandString (20 )
19+
20+ config := getRedisProDbDatasourceConfig (t , password )
2221
2322 resource .ParallelTest (t , resource.TestCase {
2423 PreCheck : func () { testAccPreCheck (t ); testAccAwsPreExistingCloudAccountPreCheck (t ) },
2524 ProviderFactories : providerFactories ,
2625 CheckDestroy : testAccCheckProSubscriptionDestroy ,
2726 Steps : []resource.TestStep {
2827 {
29- Config : fmt . Sprintf ( testAccDatasourceRedisCloudProDatabase , testCloudAccountName , name , password ) ,
28+ Config : config ,
3029 Check : resource .ComposeAggregateTestCheckFunc (
3130 resource .TestCheckResourceAttr (dataSourceById , "name" , "tf-database" ),
3231 resource .TestCheckResourceAttr (dataSourceById , "protocol" , "redis" ),
@@ -61,74 +60,22 @@ func TestAccDataSourceRedisCloudProDatabase_basic(t *testing.T) {
6160 resource .TestCheckResourceAttrSet (dataSourceByName , "private_endpoint" ),
6261 resource .TestCheckResourceAttr (dataSourceByName , "enable_default_user" , "true" ),
6362 resource .TestCheckResourceAttr (dataSourceByName , "query_performance_factor" , "2x" ),
63+ resource .TestCheckResourceAttr (dataSourceByName , "redis_version" , "7.2" ),
6464 ),
6565 },
6666 },
6767 })
68- }
6968
70- const testAccDatasourceRedisCloudProDatabase = `
71- data "rediscloud_payment_method" "card" {
72- card_type = "Visa"
73- last_four_numbers = "5556"
7469}
7570
76- data "rediscloud_cloud_account" "account" {
77- exclude_internal_account = true
78- provider_type = "AWS"
79- name = "%s"
80- }
81- resource "rediscloud_subscription" "example" {
82- name = "%s"
83- payment_method_id = data.rediscloud_payment_method.card.id
84- memory_storage = "ram"
85- cloud_provider {
86- provider = data.rediscloud_cloud_account.account.provider_type
87- cloud_account_id = data.rediscloud_cloud_account.account.id
88- region {
89- region = "eu-west-1"
90- networking_deployment_cidr = "10.0.0.0/24"
91- preferred_availability_zones = ["eu-west-1a"]
92- }
93- }
94- creation_plan {
95- memory_limit_in_gb = 1
96- quantity = 1
97- replication=false
98- support_oss_cluster_api=true
99- throughput_measurement_by = "operations-per-second"
100- throughput_measurement_value = 1000
101- query_performance_factor = "2x"
102- modules = ["RediSearch"]
103- }
104- }
105- resource "rediscloud_subscription_database" "example" {
106- subscription_id = rediscloud_subscription.example.id
107- name = "tf-database"
108- protocol = "redis"
109- memory_limit_in_gb = 1
110- data_persistence = "none"
111- throughput_measurement_by = "operations-per-second"
112- throughput_measurement_value = 1000
113- password = "%s"
114- support_oss_cluster_api = true
115- replication = false
116- enable_default_user = true
117- query_performance_factor = "2x"
118- modules = [
119- {
120- name: "RediSearch"
121- }
122- ]
123- }
71+ func getRedisProDbDatasourceConfig (t * testing.T , password string ) string {
72+ testCloudAccountName := os .Getenv ("AWS_TEST_CLOUD_ACCOUNT_NAME" )
73+ subscriptionName := acctest .RandomWithPrefix (testResourcePrefix )
12474
125- data "rediscloud_database" "example-by-id" {
126- subscription_id = rediscloud_subscription.example.id
127- db_id = rediscloud_subscription_database.example.db_id
128- }
75+ content , err := os . ReadFile ( "./testdata/testAccDatasourceRedisCloudProDatabase.tf" )
76+ if err != nil {
77+ t . Fatalf ( "failed to read file: %v" , err )
78+ }
12979
130- data "rediscloud_database" "example-by-name" {
131- subscription_id = rediscloud_subscription.example.id
132- name = rediscloud_subscription_database.example.name
80+ return fmt .Sprintf (string (content ), testCloudAccountName , subscriptionName , password )
13381}
134- `
0 commit comments