@@ -57,11 +57,17 @@ func Test_Downtime_ReadDowntime(t *testing.T) {
57
57
inID : "5ghjb6vgDFN" ,
58
58
59
59
wants : DowntimeModel {
60
- ID : types .StringValue ("5ghjb6vgDFN" ),
61
- Name : types .StringValue ("basic" ),
62
- Memo : types .StringValue ("" ),
63
- Start : types .Int64Value (1735707600 ),
64
- Duration : types .Int64Value (3600 ),
60
+ ID : types .StringValue ("5ghjb6vgDFN" ),
61
+ Name : types .StringValue ("basic" ),
62
+ Memo : types .StringValue ("" ),
63
+ Start : types .Int64Value (1735707600 ),
64
+ Duration : types .Int64Value (3600 ),
65
+ ServiceScopes : []string {},
66
+ ServiceExcludeScopes : []string {},
67
+ RoleScopes : []string {},
68
+ RoleExcludeScopes : []string {},
69
+ MonitorScopes : []string {},
70
+ MonitorExcludeScopes : []string {},
65
71
},
66
72
},
67
73
"no downtime" : {
@@ -106,17 +112,29 @@ func Test_Downtime_conv(t *testing.T) {
106
112
}{
107
113
"basic" : {
108
114
api : mackerel.Downtime {
109
- ID : "5ghjb6vgDFN" ,
110
- Name : "basic" ,
111
- Start : 1735707600 ,
112
- Duration : 3600 ,
115
+ ID : "5ghjb6vgDFN" ,
116
+ Name : "basic" ,
117
+ Start : 1735707600 ,
118
+ Duration : 3600 ,
119
+ ServiceScopes : []string {},
120
+ ServiceExcludeScopes : []string {},
121
+ RoleScopes : []string {},
122
+ RoleExcludeScopes : []string {},
123
+ MonitorScopes : []string {},
124
+ MonitorExcludeScopes : []string {},
113
125
},
114
126
model : DowntimeModel {
115
- ID : types .StringValue ("5ghjb6vgDFN" ),
116
- Name : types .StringValue ("basic" ),
117
- Memo : types .StringValue ("" ),
118
- Start : types .Int64Value (1735707600 ),
119
- Duration : types .Int64Value (3600 ),
127
+ ID : types .StringValue ("5ghjb6vgDFN" ),
128
+ Name : types .StringValue ("basic" ),
129
+ Memo : types .StringValue ("" ),
130
+ Start : types .Int64Value (1735707600 ),
131
+ Duration : types .Int64Value (3600 ),
132
+ ServiceScopes : []string {},
133
+ ServiceExcludeScopes : []string {},
134
+ RoleScopes : []string {},
135
+ RoleExcludeScopes : []string {},
136
+ MonitorScopes : []string {},
137
+ MonitorExcludeScopes : []string {},
120
138
},
121
139
},
122
140
"full" : {
@@ -183,85 +201,3 @@ func Test_Downtime_conv(t *testing.T) {
183
201
})
184
202
}
185
203
}
186
-
187
- func Test_Downtime_merge (t * testing.T ) {
188
- t .Parallel ()
189
-
190
- // in <- inNew == wants
191
- cases := map [string ]struct {
192
- in DowntimeModel
193
- inNew DowntimeModel
194
- wants DowntimeModel
195
- }{
196
- "basic" : {
197
- in : DowntimeModel {
198
- ID : types .StringValue ("5ghjb6vgDFN" ),
199
- Name : types .StringValue ("basic" ),
200
- Memo : types .StringValue ("" ),
201
- Start : types .Int64Value (1735707600 ),
202
- Duration : types .Int64Value (3600 ),
203
- Recurrence : []DowntimeRecurrence {{
204
- Type : types .StringValue ("weekly" ),
205
- Interval : types .Int64Value (2 ),
206
- Weekdays : nil ,
207
- Until : types .Int64Value (1767193199 ),
208
- }},
209
- ServiceScopes : nil ,
210
- ServiceExcludeScopes : nil ,
211
- RoleScopes : nil ,
212
- RoleExcludeScopes : nil ,
213
- MonitorScopes : nil ,
214
- MonitorExcludeScopes : []string {},
215
- },
216
- inNew : DowntimeModel {
217
- ID : types .StringValue ("5ghjb6vgDFN" ),
218
- Name : types .StringValue ("basic" ),
219
- Memo : types .StringValue ("memo" ), // changed
220
- Start : types .Int64Value (1735707600 ),
221
- Duration : types .Int64Value (3600 ),
222
- Recurrence : []DowntimeRecurrence {{
223
- Type : types .StringValue ("weekly" ),
224
- Interval : types .Int64Value (2 ),
225
- Weekdays : []string {},
226
- Until : types .Int64Value (1767193199 ),
227
- }},
228
- ServiceScopes : []string {},
229
- ServiceExcludeScopes : []string {},
230
- RoleScopes : []string {},
231
- RoleExcludeScopes : []string {},
232
- MonitorScopes : []string {},
233
- MonitorExcludeScopes : nil ,
234
- },
235
- wants : DowntimeModel {
236
- ID : types .StringValue ("5ghjb6vgDFN" ),
237
- Name : types .StringValue ("basic" ),
238
- Memo : types .StringValue ("memo" ), // changed
239
- Start : types .Int64Value (1735707600 ),
240
- Duration : types .Int64Value (3600 ),
241
- Recurrence : []DowntimeRecurrence {{
242
- Type : types .StringValue ("weekly" ),
243
- Interval : types .Int64Value (2 ),
244
- Weekdays : nil ,
245
- Until : types .Int64Value (1767193199 ),
246
- }},
247
- ServiceScopes : nil ,
248
- ServiceExcludeScopes : nil ,
249
- RoleScopes : nil ,
250
- RoleExcludeScopes : nil ,
251
- MonitorScopes : nil ,
252
- MonitorExcludeScopes : []string {},
253
- },
254
- },
255
- }
256
-
257
- for name , tt := range cases {
258
- t .Run (name , func (t * testing.T ) {
259
- t .Parallel ()
260
-
261
- tt .in .merge (tt .inNew )
262
- if diff := cmp .Diff (tt .in , tt .wants ); diff != "" {
263
- t .Error (diff )
264
- }
265
- })
266
- }
267
- }
0 commit comments