@@ -9,21 +9,22 @@ import (
99 "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
1010 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
1111 "github.com/hashicorp/terraform-plugin-testing/terraform"
12- "github.com/stackitcloud/stackit-sdk-go/core/utils"
12+ sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils"
1313
1414 "github.com/stackitcloud/stackit-sdk-go/core/config"
1515 "github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
1616 "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/wait"
1717 "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
1818 "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/testutil"
19+ "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
1920)
2021
2122// Instance resource data
2223var instanceResource = map [string ]string {
2324 "project_id" : testutil .ProjectId ,
2425 "name" : fmt .Sprintf ("tf-acc-%s" , acctest .RandStringFromCharSet (7 , acctest .CharSetAlphaNum )),
2526 "acl" : "192.168.0.0/16" ,
26- "backup_schedule" : "00 16 * * *" ,
27+ "backup_schedule" : "00 16 * * *" , // ensure it works properly with leading zeros
2728 "backup_schedule_updated" : "00 12 * * *" ,
2829 "flavor_cpu" : "2" ,
2930 "flavor_ram" : "4" ,
@@ -248,7 +249,18 @@ func TestAccPostgresFlexFlexResource(t *testing.T) {
248249 },
249250 ImportState : true ,
250251 ImportStateVerify : true ,
251- ImportStateVerifyIgnore : []string {"password" },
252+ ImportStateVerifyIgnore : []string {"password" , "backup_schedule" },
253+ ImportStateCheck : func (s []* terraform.InstanceState ) error {
254+ if len (s ) != 1 {
255+ return fmt .Errorf ("expected 1 state, got %d" , len (s ))
256+ }
257+
258+ if utils .SimplifyCronString (s [0 ].Attributes ["backup_schedule" ]) != utils .SimplifyCronString (instanceResource ["backup_schedule" ]) {
259+ return fmt .Errorf ("expected backup_schedule %s, got %s" , instanceResource ["backup_schedule" ], s [0 ].Attributes ["backup_schedule" ])
260+ }
261+
262+ return nil
263+ },
252264 },
253265 {
254266 ResourceName : "stackit_postgresflex_user.user" ,
@@ -354,7 +366,7 @@ func testAccCheckPostgresFlexDestroy(s *terraform.State) error {
354366 if items [i ].Id == nil {
355367 continue
356368 }
357- if utils .Contains (instancesToDestroy , * items [i ].Id ) {
369+ if sdkUtils .Contains (instancesToDestroy , * items [i ].Id ) {
358370 err := client .ForceDeleteInstanceExecute (ctx , testutil .ProjectId , testutil .Region , * items [i ].Id )
359371 if err != nil {
360372 return fmt .Errorf ("deleting instance %s during CheckDestroy: %w" , * items [i ].Id , err )
0 commit comments