aboutsummaryrefslogtreecommitdiffhomepage
path: root/template/functions_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'template/functions_test.go')
-rw-r--r--template/functions_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/template/functions_test.go b/template/functions_test.go
index 5e37319..4f1ec08 100644
--- a/template/functions_test.go
+++ b/template/functions_test.go
@@ -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)
+ }
+ }
+}