1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

Show attachment size on entry page

This commit is contained in:
Frédéric Guillot 2019-11-29 10:27:25 -08:00
parent 912a98788e
commit b3869a7833
4 changed files with 43 additions and 9 deletions

View file

@ -314,3 +314,22 @@ func TestProxyFilterWithHttpsInvalid(t *testing.T) {
t.Errorf(`Not expected output: got "%s" instead of "%s"`, output, expected)
}
}
func TestFormatFileSize(t *testing.T) {
scenarios := []struct {
input int64
expected string
}{
{500, "500 B"},
{1024, "1.0 KiB"},
{43520, "42.5 KiB"},
{5000 * 1024 * 1024, "4.9 GiB"},
}
for _, scenario := range scenarios {
result := formatFileSize(scenario.input)
if result != scenario.expected {
t.Errorf(`Unexpected result, got %q instead of %q for %d`, result, scenario.expected, scenario.input)
}
}
}