MCPcopy
hub / github.com/rclone/rclone / TestRWFileHandleWriteNoWrite

Function TestRWFileHandleWriteNoWrite

vfs/read_write_test.go:390–421  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

388}
389
390func TestRWFileHandleWriteNoWrite(t *testing.T) {
391 r, vfs, fh := rwHandleCreateWriteOnly(t)
392
393 // Close the file without writing to it
394 err := fh.Close()
395 if errors.Is(err, fs.ErrorCantUploadEmptyFiles) {
396 t.Logf("skipping test: %v", err)
397 return
398 }
399 assert.NoError(t, err)
400
401 // Create a different file (not in the cache)
402 h, err := vfs.OpenFile("file2", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0777)
403 require.NoError(t, err)
404
405 // Close it with Flush and Release
406 err = h.Flush()
407 assert.NoError(t, err)
408 err = h.Release()
409 assert.NoError(t, err)
410
411 // check vfs
412 root, err := vfs.Root()
413 require.NoError(t, err)
414 checkListing(t, root, []string{"file1,0,false", "file2,0,false"})
415
416 // check the underlying r.Fremote but not the modtime
417 file1 := fstest.NewItem("file1", "", t1)
418 file2 := fstest.NewItem("file2", "", t1)
419 vfs.WaitForWriters(waitForWritersDelay)
420 fstest.CheckListingWithPrecision(t, r.Fremote, []fstest.Item{file1, file2}, []string{}, fs.ModTimeNotSupported)
421}
422
423func TestRWFileHandleFlushWrite(t *testing.T) {
424 _, _, fh := rwHandleCreateWriteOnly(t)

Callers

nothing calls this directly

Calls 12

NewItemFunction · 0.92
rwHandleCreateWriteOnlyFunction · 0.85
IsMethod · 0.80
LogfMethod · 0.80
WaitForWritersMethod · 0.80
checkListingFunction · 0.70
CloseMethod · 0.65
OpenFileMethod · 0.65
FlushMethod · 0.65
ReleaseMethod · 0.65
RootMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…