MCPcopy
hub / github.com/rclone/rclone / TestFileOpenWrite

Function TestFileOpenWrite

vfs/file_test.go:231–248  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

229}
230
231func TestFileOpenWrite(t *testing.T) {
232 _, vfs, file, _ := fileCreate(t, vfscommon.CacheModeOff)
233
234 fd, err := file.openWrite(os.O_WRONLY | os.O_TRUNC)
235 require.NoError(t, err)
236
237 newContents := []byte("this is some new contents")
238 n, err := fd.Write(newContents)
239 require.NoError(t, err)
240 assert.Equal(t, len(newContents), n)
241 require.NoError(t, fd.Close())
242
243 assert.Equal(t, int64(25), file.Size())
244
245 vfs.Opt.ReadOnly = true
246 _, err = file.openWrite(os.O_WRONLY | os.O_TRUNC)
247 assert.Equal(t, EROFS, err)
248}
249
250func TestFileRemove(t *testing.T) {
251 r, vfs, file, _ := fileCreate(t, vfscommon.CacheModeOff)

Callers

nothing calls this directly

Calls 6

fileCreateFunction · 0.85
openWriteMethod · 0.80
WriteMethod · 0.65
CloseMethod · 0.65
SizeMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…