@@ -79,6 +79,7 @@ func TestAccAlloydbCluster_addAutomatedBackupPolicyAndInitialUser(t *testing.T)
79
79
80
80
context := map [string ]interface {}{
81
81
"random_suffix" : acctest .RandString (t , 10 ),
82
+ "hour" : 23 ,
82
83
}
83
84
84
85
acctest .VcrTest (t , resource.TestCase {
@@ -119,6 +120,7 @@ func TestAccAlloydbCluster_deleteAutomatedBackupPolicyAndInitialUser(t *testing.
119
120
120
121
context := map [string ]interface {}{
121
122
"random_suffix" : acctest .RandString (t , 10 ),
123
+ "hour" : 23 ,
122
124
}
123
125
124
126
acctest .VcrTest (t , resource.TestCase {
@@ -151,6 +153,37 @@ func TestAccAlloydbCluster_deleteAutomatedBackupPolicyAndInitialUser(t *testing.
151
153
})
152
154
}
153
155
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
+
154
187
func testAccAlloydbCluster_withInitialUserAndAutomatedBackupPolicy (context map [string ]interface {}) string {
155
188
return acctest .Nprintf (`
156
189
resource "google_alloydb_cluster" "default" {
@@ -172,7 +205,7 @@ resource "google_alloydb_cluster" "default" {
172
205
days_of_week = ["MONDAY"]
173
206
174
207
start_times {
175
- hours = 23
208
+ hours = %{hour}
176
209
minutes = 0
177
210
seconds = 0
178
211
nanos = 0
0 commit comments