Skip to content

Commit

Permalink
test(utils): unit test for SizeToStorageUnits
Browse files Browse the repository at this point in the history
  • Loading branch information
luisnquin committed Feb 3, 2024
1 parent 725a60d commit 527f334
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions internal/utils/storage_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package utils_test

import (
"testing"

"github.com/luisnquin/nao/v3/internal/utils"
)

func TestSizeToStorageUnits(t *testing.T) {
tests := []struct {
input int64
expected string
}{
{1500000, "1.43MB"},
{2000000000, "1.86GB"},
{5000, "4.88KB"},
{0, "0.00KB"},
{999, "0.98KB"},
{100000000000, "93.13GB"},
{-100, "-0.10KB"},
}

for _, test := range tests {
result := utils.SizeToStorageUnits(test.input)
if result != test.expected {
t.Errorf("For input %d, expected %s, but got %s", test.input, test.expected, result)
}
}
}

0 comments on commit 527f334

Please sign in to comment.