@@ -79,6 +79,7 @@ func TestAccAlloydbCluster_addAutomatedBackupPolicyAndInitialUser(t *testing.T)
7979
8080 context := map [string ]interface {}{
8181 "random_suffix" : acctest .RandString (t , 10 ),
82+ "hour" : 23 ,
8283 }
8384
8485 acctest .VcrTest (t , resource.TestCase {
@@ -119,6 +120,7 @@ func TestAccAlloydbCluster_deleteAutomatedBackupPolicyAndInitialUser(t *testing.
119120
120121 context := map [string ]interface {}{
121122 "random_suffix" : acctest .RandString (t , 10 ),
123+ "hour" : 23 ,
122124 }
123125
124126 acctest .VcrTest (t , resource.TestCase {
@@ -151,6 +153,37 @@ func TestAccAlloydbCluster_deleteAutomatedBackupPolicyAndInitialUser(t *testing.
151153 })
152154}
153155
156+ // Test if automatedBackupPolicy properly handles a startTime of 0 (aka midnight). Calling terraform plan
157+ // after creating the cluster should not bring anything up.
158+ func TestAccAlloydbCluster_AutomatedBackupPolicyHandlesMidnight (t * testing.T ) {
159+ t .Parallel ()
160+
161+ context := map [string ]interface {}{
162+ "random_suffix" : acctest .RandString (t , 10 ),
163+ "hour" : 0 ,
164+ }
165+
166+ acctest .VcrTest (t , resource.TestCase {
167+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
168+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
169+ CheckDestroy : testAccCheckAlloydbClusterDestroyProducer (t ),
170+ Steps : []resource.TestStep {
171+ {
172+ Config : testAccAlloydbCluster_withInitialUserAndAutomatedBackupPolicy (context ),
173+ },
174+ {
175+ ResourceName : "google_alloydb_cluster.default" ,
176+ ImportState : true ,
177+ ImportStateVerify : true ,
178+ ImportStateVerifyIgnore : []string {"initial_user" , "cluster_id" , "location" },
179+ },
180+ {
181+ Config : testAccAlloydbCluster_alloydbClusterBasicExample (context ),
182+ },
183+ },
184+ })
185+ }
186+
154187func testAccAlloydbCluster_withInitialUserAndAutomatedBackupPolicy (context map [string ]interface {}) string {
155188 return acctest .Nprintf (`
156189resource "google_alloydb_cluster" "default" {
@@ -172,7 +205,7 @@ resource "google_alloydb_cluster" "default" {
172205 days_of_week = ["MONDAY"]
173206
174207 start_times {
175- hours = 23
208+ hours = %{hour}
176209 minutes = 0
177210 seconds = 0
178211 nanos = 0
0 commit comments