diff --git a/config/maintenance/maintenance.go b/config/maintenance/maintenance.go index fe721477..dc66fefe 100644 --- a/config/maintenance/maintenance.go +++ b/config/maintenance/maintenance.go @@ -82,7 +82,7 @@ func (c *Config) ValidateAndSetDefaults() error { if err != nil { return err } - if c.Duration <= 0 || c.Duration >= 24*time.Hour { + if c.Duration <= 0 || c.Duration > 24*time.Hour { return errInvalidMaintenanceDuration } return nil diff --git a/config/maintenance/maintenance_test.go b/config/maintenance/maintenance_test.go index 7f97734e..76ef9eb2 100644 --- a/config/maintenance/maintenance_test.go +++ b/config/maintenance/maintenance_test.go @@ -211,6 +211,14 @@ func TestConfig_IsUnderMaintenance(t *testing.T) { }, expected: true, }, + { + name: "under-maintenance-starting-22h-ago-for-24h", + cfg: &Config{ + Start: fmt.Sprintf("%02d:00", normalizeHour(now.Hour()-22)), + Duration: 24 * time.Hour, + }, + expected: true, + }, { name: "under-maintenance-starting-4h-ago-for-3h", cfg: &Config{ @@ -236,6 +244,15 @@ func TestConfig_IsUnderMaintenance(t *testing.T) { }, expected: false, }, + { + name: "not-under-maintenance-today-with-24h-duration", + cfg: &Config{ + Start: fmt.Sprintf("%02d:00", now.Hour()), + Duration: 24 * time.Hour, + Every: []string{now.Add(48 * time.Hour).Weekday().String()}, + }, + expected: false, + }, } for _, scenario := range scenarios { t.Run(scenario.name, func(t *testing.T) {