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

refactor(fetcher): use time.Duration for client timeout values

All functions use time.Duration, so instead of converting everywhere, do it once.
This commit is contained in:
gudvinr 2025-08-18 23:10:18 +03:00 committed by Frédéric Guillot
parent 71af68becd
commit 30453ad7ec
5 changed files with 51 additions and 22 deletions

View file

@ -1607,12 +1607,22 @@ func TestMediaProxyHTTPClientTimeout(t *testing.T) {
t.Fatalf(`Parsing failure: %v`, err)
}
expected := 24
expected := 24 * time.Second
result := opts.MediaProxyHTTPClientTimeout()
if result != expected {
t.Fatalf(`Unexpected MEDIA_PROXY_HTTP_CLIENT_TIMEOUT value, got %d instead of %d`, result, expected)
}
sorted := opts.SortedOptions(false)
i := slices.IndexFunc(sorted, func(opt *option) bool {
return opt.Key == "MEDIA_PROXY_HTTP_CLIENT_TIMEOUT"
})
expectedSerialized := 24
if got := sorted[i].Value; got != expectedSerialized {
t.Fatalf(`Unexpected value in option output, got %q instead of %q`, got, expectedSerialized)
}
}
func TestDefaultMediaProxyHTTPClientTimeoutValue(t *testing.T) {
@ -1630,6 +1640,16 @@ func TestDefaultMediaProxyHTTPClientTimeoutValue(t *testing.T) {
if result != expected {
t.Fatalf(`Unexpected MEDIA_PROXY_HTTP_CLIENT_TIMEOUT value, got %d instead of %d`, result, expected)
}
sorted := opts.SortedOptions(false)
i := slices.IndexFunc(sorted, func(opt *option) bool {
return opt.Key == "MEDIA_PROXY_HTTP_CLIENT_TIMEOUT"
})
expectedSerialized := int(defaultMediaProxyHTTPClientTimeout / time.Second)
if got := sorted[i].Value; got != expectedSerialized {
t.Fatalf(`Unexpected value in option output, got %q instead of %q`, got, expectedSerialized)
}
}
func TestMediaProxyCustomURL(t *testing.T) {
@ -1706,12 +1726,22 @@ func TestHTTPClientTimeout(t *testing.T) {
t.Fatalf(`Parsing failure: %v`, err)
}
expected := 42
expected := 42 * time.Second
result := opts.HTTPClientTimeout()
if result != expected {
t.Fatalf(`Unexpected HTTP_CLIENT_TIMEOUT value, got %d instead of %d`, result, expected)
}
sorted := opts.SortedOptions(false)
i := slices.IndexFunc(sorted, func(opt *option) bool {
return opt.Key == "HTTP_CLIENT_TIMEOUT"
})
expectedSerialized := 42
if got := sorted[i].Value; got != expectedSerialized {
t.Fatalf(`Unexpected value in option output, got %q instead of %q`, got, expectedSerialized)
}
}
func TestDefaultHTTPClientTimeoutValue(t *testing.T) {