@@ -3,6 +3,7 @@ package provider
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "regexp"
6
7
"testing"
7
8
8
9
dfcloud "github.com/dragonflydb/terraform-provider-dfcloud/internal/sdk"
@@ -75,6 +76,8 @@ func TestAcc_DatastoreResource(t *testing.T) {
75
76
resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "tier.replicas" , "1" ),
76
77
resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "dragonfly.cache_mode" , "false" ),
77
78
resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "dragonfly.tls" , "false" ),
79
+ resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "dragonfly.acl_rules.#" , "1" ),
80
+ resource .TestMatchResourceAttr ("dfcloud_datastore.test" , "dragonfly.acl_rules.0" , regexp .MustCompile (`USER default ON \>([a-zA-Z0-9]+) ~\* &\* \+@ALL` )),
78
81
resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "id" ),
79
82
resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "addr" ),
80
83
resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "created_at" ),
@@ -87,6 +90,28 @@ func TestAcc_DatastoreResource(t *testing.T) {
87
90
ImportState : true ,
88
91
ImportStateVerify : true ,
89
92
},
93
+ {
94
+ Config : testAccDatastoreResourceConfigUpdated (name ),
95
+ Check : resource .ComposeAggregateTestCheckFunc (
96
+ testCheckDatastoreExists ("dfcloud_datastore.test" ),
97
+ resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "name" , name ),
98
+ resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "location.provider" , "aws" ),
99
+ resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "location.region" , "eu-west-1" ),
100
+ resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "location.availability_zones.#" , "1" ),
101
+ resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "location.availability_zones.0" , "euw1-az2" ),
102
+ resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "tier.performance_tier" , "dev" ),
103
+ resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "tier.max_memory_bytes" , "3000000000" ),
104
+ resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "tier.replicas" , "0" ),
105
+ resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "dragonfly.cache_mode" , "false" ),
106
+ resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "dragonfly.tls" , "false" ),
107
+ resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "dragonfly.acl_rules.#" , "1" ),
108
+ resource .TestMatchResourceAttr ("dfcloud_datastore.test" , "dragonfly.acl_rules.0" , regexp .MustCompile (`USER default ON \>([a-zA-Z0-9]+) ~\* &\* \+@ALL` )),
109
+ resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "id" ),
110
+ resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "addr" ),
111
+ resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "created_at" ),
112
+ resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "password" ),
113
+ ),
114
+ },
90
115
},
91
116
})
92
117
}
@@ -115,6 +140,9 @@ func TestAcc_DatastoreResource_withCluster(t *testing.T) {
115
140
resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "tier.replicas" , "1" ),
116
141
resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "dragonfly.cache_mode" , "false" ),
117
142
resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "dragonfly.tls" , "false" ),
143
+ resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "dragonfly.acl_rules.#" , "1" ),
144
+ resource .TestMatchResourceAttr ("dfcloud_datastore.test" , "dragonfly.acl_rules.0" , regexp .MustCompile (`USER default ON \>([a-zA-Z0-9]+) ~\* &\* \+@ALL` )),
145
+ resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "location.availability_zones.0" , "euw1-az2" ),
118
146
resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "id" ),
119
147
resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "addr" ),
120
148
resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "created_at" ),
@@ -174,3 +202,23 @@ resource "dfcloud_datastore" "test" {
174
202
}
175
203
` , name )
176
204
}
205
+
206
+ func testAccDatastoreResourceConfigUpdated (name string ) string {
207
+ return fmt .Sprintf (`
208
+ resource "dfcloud_datastore" "test" {
209
+ name = %[1]q
210
+
211
+ location = {
212
+ provider = "aws"
213
+ region = "eu-west-1"
214
+ availability_zones = ["euw1-az2"]
215
+ }
216
+
217
+ tier = {
218
+ max_memory_bytes = 3000000000 # 3GB
219
+ performance_tier = "dev"
220
+ replicas = 0
221
+ }
222
+ }
223
+ ` , name )
224
+ }
0 commit comments