@@ -3,6 +3,7 @@ package provider
33import (
44 "context"
55 "fmt"
6+ "regexp"
67 "testing"
78
89 dfcloud "github.com/dragonflydb/terraform-provider-dfcloud/internal/sdk"
@@ -75,6 +76,8 @@ func TestAcc_DatastoreResource(t *testing.T) {
7576 resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "tier.replicas" , "1" ),
7677 resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "dragonfly.cache_mode" , "false" ),
7778 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` )),
7881 resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "id" ),
7982 resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "addr" ),
8083 resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "created_at" ),
@@ -87,6 +90,28 @@ func TestAcc_DatastoreResource(t *testing.T) {
8790 ImportState : true ,
8891 ImportStateVerify : true ,
8992 },
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+ },
90115 },
91116 })
92117}
@@ -115,6 +140,9 @@ func TestAcc_DatastoreResource_withCluster(t *testing.T) {
115140 resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "tier.replicas" , "1" ),
116141 resource .TestCheckResourceAttr ("dfcloud_datastore.test" , "dragonfly.cache_mode" , "false" ),
117142 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" ),
118146 resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "id" ),
119147 resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "addr" ),
120148 resource .TestCheckResourceAttrSet ("dfcloud_datastore.test" , "created_at" ),
@@ -174,3 +202,23 @@ resource "dfcloud_datastore" "test" {
174202}
175203` , name )
176204}
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