1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-24 04:04:37 +00:00

vfs: add tests and subsequent fixes

* Tests for VFS layer
  * Small fixes found during testing
  * Fix Close, Flush and Release behaviour for ReadFileHandle and WriteFileHandle
  * Fix nil object bugs on File
This commit is contained in:
Nick Craig-Wood
2017-10-29 21:14:05 +00:00
parent 07ec8073fe
commit e18122e88b
18 changed files with 1536 additions and 59 deletions

29
vfs/createinfo_test.go Normal file
View File

@@ -0,0 +1,29 @@
package vfs
import (
"testing"
"time"
"github.com/ncw/rclone/fs"
"github.com/ncw/rclone/fstest"
"github.com/stretchr/testify/assert"
)
func TestCreateInfo(t *testing.T) {
r := fstest.NewRun(t)
defer r.Finalise()
remote := "file/to/be/created"
ci := newCreateInfo(r.Fremote, remote)
// Test methods
assert.Equal(t, r.Fremote, ci.Fs())
assert.Equal(t, remote, ci.String())
assert.Equal(t, remote, ci.Remote())
_, err := ci.Hash(fs.HashMD5)
assert.Equal(t, fs.ErrHashUnsupported, err)
assert.WithinDuration(t, time.Now(), ci.ModTime(), time.Second)
assert.Equal(t, int64(0), ci.Size())
assert.Equal(t, true, ci.Storable())
}