22 lines
577 B
Go
22 lines
577 B
Go
|
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)
|
||
|
}
|
||
|
}
|
||
|
}
|