mirror of
https://github.com/miniflux/v2.git
synced 2025-08-26 18:21:01 +00:00
refactor(cli): use time.Duration for cleanup tasks
This commit is contained in:
parent
7060ecc163
commit
983291c78b
8 changed files with 94 additions and 45 deletions
|
@ -645,12 +645,22 @@ func TestDefaultCleanupArchiveReadDaysValue(t *testing.T) {
|
|||
t.Fatalf(`Parsing failure: %v`, err)
|
||||
}
|
||||
|
||||
expected := 60
|
||||
result := opts.CleanupArchiveReadDays()
|
||||
expected := 60 * 24 * time.Hour
|
||||
result := opts.CleanupArchiveReadInterval()
|
||||
|
||||
if result != expected {
|
||||
t.Fatalf(`Unexpected CLEANUP_ARCHIVE_READ_DAYS value, got %v instead of %v`, result, expected)
|
||||
}
|
||||
|
||||
sorted := opts.SortedOptions(false)
|
||||
i := slices.IndexFunc(sorted, func(opt *option) bool {
|
||||
return opt.Key == "CLEANUP_ARCHIVE_READ_DAYS"
|
||||
})
|
||||
|
||||
expectedSerialized := 60
|
||||
if got := sorted[i].Value; got != expectedSerialized {
|
||||
t.Fatalf(`Unexpected value in option output, got %q instead of %q`, got, expectedSerialized)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCleanupArchiveReadDays(t *testing.T) {
|
||||
|
@ -664,12 +674,22 @@ func TestCleanupArchiveReadDays(t *testing.T) {
|
|||
t.Fatalf(`Parsing failure: %v`, err)
|
||||
}
|
||||
|
||||
expected := 7
|
||||
result := opts.CleanupArchiveReadDays()
|
||||
expected := 7 * 24 * time.Hour
|
||||
result := opts.CleanupArchiveReadInterval()
|
||||
|
||||
if result != expected {
|
||||
t.Fatalf(`Unexpected CLEANUP_ARCHIVE_READ_DAYS value, got %v instead of %v`, result, expected)
|
||||
}
|
||||
|
||||
sorted := opts.SortedOptions(false)
|
||||
i := slices.IndexFunc(sorted, func(opt *option) bool {
|
||||
return opt.Key == "CLEANUP_ARCHIVE_READ_DAYS"
|
||||
})
|
||||
|
||||
expectedSerialized := 7
|
||||
if got := sorted[i].Value; got != expectedSerialized {
|
||||
t.Fatalf(`Unexpected value in option output, got %q instead of %q`, got, expectedSerialized)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultCleanupRemoveSessionsDaysValue(t *testing.T) {
|
||||
|
@ -681,12 +701,22 @@ func TestDefaultCleanupRemoveSessionsDaysValue(t *testing.T) {
|
|||
t.Fatalf(`Parsing failure: %v`, err)
|
||||
}
|
||||
|
||||
expected := 30
|
||||
result := opts.CleanupRemoveSessionsDays()
|
||||
expected := 30 * 24 * time.Hour
|
||||
result := opts.CleanupRemoveSessionsInterval()
|
||||
|
||||
if result != expected {
|
||||
t.Fatalf(`Unexpected CLEANUP_REMOVE_SESSIONS_DAYS value, got %v instead of %v`, result, expected)
|
||||
}
|
||||
|
||||
sorted := opts.SortedOptions(false)
|
||||
i := slices.IndexFunc(sorted, func(opt *option) bool {
|
||||
return opt.Key == "CLEANUP_REMOVE_SESSIONS_DAYS"
|
||||
})
|
||||
|
||||
expectedSerialized := 30
|
||||
if got := sorted[i].Value; got != expectedSerialized {
|
||||
t.Fatalf(`Unexpected value in option output, got %q instead of %q`, got, expectedSerialized)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCleanupRemoveSessionsDays(t *testing.T) {
|
||||
|
@ -699,12 +729,22 @@ func TestCleanupRemoveSessionsDays(t *testing.T) {
|
|||
t.Fatalf(`Parsing failure: %v`, err)
|
||||
}
|
||||
|
||||
expected := 7
|
||||
result := opts.CleanupRemoveSessionsDays()
|
||||
expected := 7 * 24 * time.Hour
|
||||
result := opts.CleanupRemoveSessionsInterval()
|
||||
|
||||
if result != expected {
|
||||
t.Fatalf(`Unexpected CLEANUP_REMOVE_SESSIONS_DAYS value, got %v instead of %v`, result, expected)
|
||||
}
|
||||
|
||||
sorted := opts.SortedOptions(false)
|
||||
i := slices.IndexFunc(sorted, func(opt *option) bool {
|
||||
return opt.Key == "CLEANUP_REMOVE_SESSIONS_DAYS"
|
||||
})
|
||||
|
||||
expectedSerialized := 7
|
||||
if got := sorted[i].Value; got != expectedSerialized {
|
||||
t.Fatalf(`Unexpected value in option output, got %q instead of %q`, got, expectedSerialized)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultWorkerPoolSizeValue(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue