@@ -36,6 +36,8 @@ func TestAccFeatureResource(t *testing.T) {
3636 resource .TestCheckResourceAttr ("flagsmith_feature.test_feature" , "owners.0" , fmt .Sprintf ("%d" , firstUserID )),
3737 resource .TestCheckResourceAttr ("flagsmith_feature.test_feature" , "owners.1" , fmt .Sprintf ("%d" , secondUserID )),
3838
39+ resource .TestCheckResourceAttrSet ("flagsmith_feature.test_feature" , "tags.0" ),
40+
3941 resource .TestCheckResourceAttrSet ("flagsmith_feature.test_feature" , "id" ),
4042 resource .TestCheckResourceAttrSet ("flagsmith_feature.test_feature" , "uuid" ),
4143 resource .TestCheckResourceAttrSet ("flagsmith_feature.test_feature" , "project_id" ),
@@ -56,6 +58,8 @@ func TestAccFeatureResource(t *testing.T) {
5658 resource .TestCheckResourceAttr ("flagsmith_feature.test_feature" , "owners.0" , fmt .Sprintf ("%d" , firstUserID )),
5759 resource .TestCheckResourceAttr ("flagsmith_feature.test_feature" , "owners.1" , fmt .Sprintf ("%d" , secondUserID )),
5860
61+ resource .TestCheckResourceAttrSet ("flagsmith_feature.test_feature" , "tags.0" ),
62+
5963 resource .TestCheckResourceAttrSet ("flagsmith_feature.test_feature" , "id" ),
6064 resource .TestCheckResourceAttrSet ("flagsmith_feature.test_feature" , "uuid" ),
6165 resource .TestCheckResourceAttrSet ("flagsmith_feature.test_feature" , "project_id" ),
@@ -70,6 +74,8 @@ func TestAccFeatureResource(t *testing.T) {
7074 resource .TestCheckResourceAttr ("flagsmith_feature.test_feature" , "description" , "feature description updated" ),
7175 resource .TestCheckResourceAttr ("flagsmith_feature.test_feature" , "project_uuid" , projectUUID ()),
7276
77+ resource .TestCheckResourceAttrSet ("flagsmith_feature.test_feature" , "tags.0" ),
78+
7379 resource .TestCheckResourceAttr ("flagsmith_feature.test_feature" , "owners.0" , fmt .Sprintf ("%d" , firstUserID )),
7480 resource .TestCheckResourceAttr ("flagsmith_feature.test_feature" , "owners.1" , fmt .Sprintf ("%d" , thirdUserID )),
7581 ),
@@ -136,14 +142,15 @@ func TestAccFeatureResourceOwners(t *testing.T) {
136142 },
137143 })
138144}
145+
139146func getFeatureImportID (n string ) resource.ImportStateIdFunc {
140147 return func (s * terraform.State ) (string , error ) {
141- return getUUIDfromState (s , n )
148+ return getAttributefromState (s , n , "uuid" )
142149 }
143150}
144151
145152func testAccCheckFeatureResourceDestroy (s * terraform.State ) error {
146- uuid , err := getUUIDfromState (s , "flagsmith_feature.test_feature" )
153+ uuid , err := getAttributefromState (s , "flagsmith_feature.test_feature" , "uuid " )
147154 if err != nil {
148155 return err
149156 }
@@ -156,33 +163,25 @@ func testAccCheckFeatureResourceDestroy(s *terraform.State) error {
156163
157164}
158165
159- func getUUIDfromState (s * terraform.State , resourceName string ) (string , error ) {
160- rs , ok := s .RootModule ().Resources [resourceName ]
161- if ! ok {
162- return "" , fmt .Errorf ("not found: %s" , resourceName )
163- }
164-
165- uuid := rs .Primary .Attributes ["uuid" ]
166-
167- if uuid == "" {
168- return "" , fmt .Errorf ("no uuid is set" )
169- }
170- return uuid , nil
171- }
172-
173166func testAccFeatureResourceConfig (featureName , description string , owners []int ) string {
174167 return fmt .Sprintf (`
175168provider "flagsmith" {
176169
177170}
171+ resource "flagsmith_tag" "test_tag" {
172+ tag_name = "feature_acc_test_tag"
173+ tag_colour = "#000000"
174+ project_uuid = "%s"
175+ }
178176
179177resource "flagsmith_feature" "test_feature" {
180178 feature_name = "%s"
181179 description = "%s"
182180 project_uuid = "%s"
183181 type = "STANDARD"
184182 owners = %s
183+ tags = [flagsmith_tag.test_tag.id]
185184}
186185
187- ` , featureName , description , projectUUID (), strings .Join (strings .Fields (fmt .Sprint (owners )), "," ))
186+ ` , projectUUID (), featureName , description , projectUUID (), strings .Join (strings .Fields (fmt .Sprint (owners )), "," ))
188187}
0 commit comments