utils/filesystem_test.go

22 lines
577 B
Go
Raw Normal View History

2023-10-13 20:38:08 +02:00
package utils
import (
"testing"
)
func TestGetSizeOfFileInBytes(t *testing.T) {
data := map[string]int64{
"/usr/bin/go": 11466992, // ls -lH /usr/bin/go | awk -F ' ' '{print $5}'
"/etc/fstab": 1049, // ls -lH /etc/fstab | awk -F ' ' '{print $5}'
"/etc/os-release": 371, // ls -lH /etc/os-release | awk -F ' ' '{print $5}'
"/etc": 0,
}
for d, expectedResult := range data {
result, _ := GetSizeOfFileInBytes(d)
if result != expectedResult {
t.Errorf("\ngot: %d\nwanted: %d\nfor: %q", result, expectedResult, d)
}
}
}