Commit 92b04d06 authored by Nicolas Pernoud's avatar Nicolas Pernoud
Browse files

fix: added test for diskusage

parent 6d56102f
Pipeline #8924 passed with stages
in 2 minutes and 21 seconds
// +build !windows
package du
import (
"testing"
)
func TestNewDiskUsage(t *testing.T) {
type args struct {
volumePath string
}
tests := []struct {
name string
args args
wantErr bool
}{
{"must_be_getting_usage", args{volumePath: "/"}, false},
{"must_error", args{volumePath: "not_a_path"}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := NewDiskUsage(tt.args.volumePath)
if (err != nil) != tt.wantErr {
t.Errorf("NewDiskUsage() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !tt.wantErr && (got.Size() <= 0 || got.Free() <= 0) {
t.Errorf("DiskUsage sizes must be > 0 ; got size : %v, free : %v", got.Size(), got.Free())
}
})
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment