vfs: make tests work on remotes which don't support About

This commit is contained in:
Nick Craig-Wood 2019-02-27 17:13:54 +00:00
parent 173dfbd051
commit b353c730d8

View File

@ -263,24 +263,32 @@ func TestVFSStatfs(t *testing.T) {
assert.Nil(t, vfs.usage) assert.Nil(t, vfs.usage)
assert.True(t, vfs.usageTime.IsZero()) assert.True(t, vfs.usageTime.IsZero())
aboutSupported := r.Fremote.Features().About != nil
// read // read
total, used, free := vfs.Statfs() total, used, free := vfs.Statfs()
if !aboutSupported {
assert.Equal(t, int64(-1), total)
assert.Equal(t, int64(-1), free)
assert.Equal(t, int64(-1), used)
return // can't test anything else if About not supported
}
require.NotNil(t, vfs.usage) require.NotNil(t, vfs.usage)
assert.False(t, vfs.usageTime.IsZero()) assert.False(t, vfs.usageTime.IsZero())
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, -1, total) assert.Equal(t, int64(-1), total)
} }
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, -1, free) assert.Equal(t, int64(-1), free)
} }
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, -1, used) assert.Equal(t, int64(-1), used)
} }
// read cached // read cached