Skip to content

Commit 9be5db8

Browse files
committed
Missing tests.
1 parent f059ff2 commit 9be5db8

File tree

5 files changed

+646
-45
lines changed

5 files changed

+646
-45
lines changed

internal/kibana/maintenance_window/models.go

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ func (model MaintenanceWindowModel) toAPIUpdateRequest(ctx context.Context) (kba
256256
}
257257

258258
if model.Scope != nil {
259-
// Yes, I hate it too
260259
body.Scope = &struct {
261260
Alerting struct {
262261
Query struct {
@@ -315,36 +314,6 @@ func (model MaintenanceWindowModel) getMaintenanceWindowIDAndSpaceID() (maintena
315314

316315
/* RESPONSE HANDLER */
317316

318-
type ResponseJson struct {
319-
CreatedAt string `json:"created_at"`
320-
CreatedBy *string `json:"created_by"`
321-
Enabled bool `json:"enabled"`
322-
Id string `json:"id"`
323-
Schedule struct {
324-
Custom struct {
325-
Duration string `json:"duration"`
326-
Recurring *struct {
327-
End *string `json:"end,omitempty"`
328-
Every *string `json:"every,omitempty"`
329-
Occurrences *float32 `json:"occurrences,omitempty"`
330-
OnMonth *[]float32 `json:"onMonth,omitempty"`
331-
OnMonthDay *[]float32 `json:"onMonthDay,omitempty"`
332-
OnWeekDay *[]string `json:"onWeekDay,omitempty"`
333-
} `json:"recurring,omitempty"`
334-
Start string `json:"start"`
335-
Timezone *string `json:"timezone,omitempty"`
336-
} `json:"custom"`
337-
} `json:"schedule"`
338-
Scope *struct {
339-
Alerting struct {
340-
Query struct {
341-
Kql string `json:"kql"`
342-
} `json:"query"`
343-
} `json:"alerting"`
344-
} `json:"scope,omitempty"`
345-
Title string `json:"title"`
346-
}
347-
348317
func (model *MaintenanceWindowModel) _fromAPIResponse(ctx context.Context, response ResponseJson) diag.Diagnostics {
349318

350319
var diags diag.Diagnostics
@@ -369,8 +338,8 @@ func (model *MaintenanceWindowModel) _fromAPIResponse(ctx context.Context, respo
369338
End: types.StringPointerValue(response.Schedule.Custom.Recurring.End),
370339
Every: types.StringPointerValue(response.Schedule.Custom.Recurring.Every),
371340
OnWeekDay: types.ListNull(types.StringType),
372-
OnMonth: types.ListNull(types.Float32Type),
373-
OnMonthDay: types.ListNull(types.Float32Type),
341+
OnMonth: types.ListNull(types.Int32Type),
342+
OnMonthDay: types.ListNull(types.Int32Type),
374343
}
375344

376345
if response.Schedule.Custom.Recurring.Occurrences != nil {
@@ -384,12 +353,12 @@ func (model *MaintenanceWindowModel) _fromAPIResponse(ctx context.Context, respo
384353
}
385354

386355
if response.Schedule.Custom.Recurring.OnMonth != nil {
387-
onMonth, _ := types.ListValueFrom(ctx, types.Float32Type, response.Schedule.Custom.Recurring.OnMonth)
356+
onMonth, _ := types.ListValueFrom(ctx, types.Int32Type, response.Schedule.Custom.Recurring.OnMonth)
388357
model.CustomSchedule.Recurring.OnMonth = onMonth
389358
}
390359

391360
if response.Schedule.Custom.Recurring.OnMonthDay != nil {
392-
onMonthDay, _ := types.ListValueFrom(ctx, types.Float32Type, response.Schedule.Custom.Recurring.OnMonthDay)
361+
onMonthDay, _ := types.ListValueFrom(ctx, types.Int32Type, response.Schedule.Custom.Recurring.OnMonthDay)
393362
model.CustomSchedule.Recurring.OnMonthDay = onMonthDay
394363
}
395364
}

0 commit comments

Comments
 (0)