1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

refactor(cli): use time.Duration for scheduler frequency

Polling frequency is undocumented so it's not exacly clear what units were.
This commit is contained in:
gudvinr 2025-08-18 23:10:18 +03:00 committed by Frédéric Guillot
parent 4af12a4129
commit 7060ecc163
4 changed files with 63 additions and 23 deletions

View file

@ -589,12 +589,22 @@ func TestDefaultCleanupFrequencyHoursValue(t *testing.T) {
t.Fatalf(`Parsing failure: %v`, err)
}
expected := defaultCleanupFrequencyHours
result := opts.CleanupFrequencyHours()
expected := defaultCleanupFrequency
result := opts.CleanupFrequency()
if result != expected {
t.Fatalf(`Unexpected CLEANUP_FREQUENCY_HOURS value, got %v instead of %v`, result, expected)
}
sorted := opts.SortedOptions(false)
i := slices.IndexFunc(sorted, func(opt *option) bool {
return opt.Key == "CLEANUP_FREQUENCY_HOURS"
})
expectedSerialized := int(defaultCleanupFrequency / time.Hour)
if got := sorted[i].Value; got != expectedSerialized {
t.Fatalf(`Unexpected value in option output, got %q instead of %q`, got, expectedSerialized)
}
}
func TestCleanupFrequencyHours(t *testing.T) {
@ -608,12 +618,22 @@ func TestCleanupFrequencyHours(t *testing.T) {
t.Fatalf(`Parsing failure: %v`, err)
}
expected := 42
result := opts.CleanupFrequencyHours()
expected := 42 * time.Hour
result := opts.CleanupFrequency()
if result != expected {
t.Fatalf(`Unexpected CLEANUP_FREQUENCY_HOURS value, got %v instead of %v`, result, expected)
}
sorted := opts.SortedOptions(false)
i := slices.IndexFunc(sorted, func(opt *option) bool {
return opt.Key == "CLEANUP_FREQUENCY_HOURS"
})
expectedSerialized := 42
if got := sorted[i].Value; got != expectedSerialized {
t.Fatalf(`Unexpected value in option output, got %q instead of %q`, got, expectedSerialized)
}
}
func TestDefaultCleanupArchiveReadDaysValue(t *testing.T) {
@ -737,6 +757,16 @@ func TestDefaultPollingFrequencyValue(t *testing.T) {
if result != expected {
t.Fatalf(`Unexpected POLLING_FREQUENCY value, got %v instead of %v`, result, expected)
}
sorted := opts.SortedOptions(false)
i := slices.IndexFunc(sorted, func(opt *option) bool {
return opt.Key == "POLLING_FREQUENCY"
})
expectedSerialized := int(defaultPollingFrequency / time.Minute)
if got := sorted[i].Value; got != expectedSerialized {
t.Fatalf(`Unexpected value in option output, got %q instead of %q`, got, expectedSerialized)
}
}
func TestPollingFrequency(t *testing.T) {
@ -749,12 +779,22 @@ func TestPollingFrequency(t *testing.T) {
t.Fatalf(`Parsing failure: %v`, err)
}
expected := 42
expected := 42 * time.Minute
result := opts.PollingFrequency()
if result != expected {
t.Fatalf(`Unexpected POLLING_FREQUENCY value, got %v instead of %v`, result, expected)
}
sorted := opts.SortedOptions(false)
i := slices.IndexFunc(sorted, func(opt *option) bool {
return opt.Key == "POLLING_FREQUENCY"
})
expectedSerialized := 42
if got := sorted[i].Value; got != expectedSerialized {
t.Fatalf(`Unexpected value in option output, got %q instead of %q`, got, expectedSerialized)
}
}
func TestDefaultForceRefreshInterval(t *testing.T) {