vfs: fix tests for Statfs when running on backends with unknowns

This was broken in da41db4712
This commit is contained in:
Nick Craig-Wood 2020-04-22 17:56:45 +01:00
parent 8176202e6d
commit 86eaf43b00

View file

@ -280,9 +280,9 @@ func TestVFSStatfs(t *testing.T) {
// read // read
total, used, free := vfs.Statfs() total, used, free := vfs.Statfs()
if !aboutSupported { if !aboutSupported {
assert.Equal(t, int64(-1), total) assert.Equal(t, int64(unknownFreeBytes), total)
assert.Equal(t, int64(-1), free) assert.Equal(t, int64(unknownFreeBytes), free)
assert.Equal(t, int64(-1), used) assert.Equal(t, int64(0), used)
return // can't test anything else if About not supported return // can't test anything else if About not supported
} }
require.NotNil(t, vfs.usage) require.NotNil(t, vfs.usage)
@ -290,17 +290,17 @@ func TestVFSStatfs(t *testing.T) {
if vfs.usage.Total != nil { if vfs.usage.Total != nil {
assert.Equal(t, *vfs.usage.Total, total) assert.Equal(t, *vfs.usage.Total, total)
} else { } else {
assert.Equal(t, int64(-1), total) assert.True(t, total >= int64(unknownFreeBytes))
} }
if vfs.usage.Free != nil { if vfs.usage.Free != nil {
assert.Equal(t, *vfs.usage.Free, free) assert.Equal(t, *vfs.usage.Free, free)
} else { } else {
assert.Equal(t, int64(-1), free) assert.True(t, free >= int64(unknownFreeBytes))
} }
if vfs.usage.Used != nil { if vfs.usage.Used != nil {
assert.Equal(t, *vfs.usage.Used, used) assert.Equal(t, *vfs.usage.Used, used)
} else { } else {
assert.Equal(t, int64(-1), used) assert.Equal(t, int64(0), used)
} }
// read cached // read cached