MCPcopy
hub / github.com/rclone/rclone / TestWriteBackAddUpdateNotStarted

Function TestWriteBackAddUpdateNotStarted

vfs/vfscache/writeback/writeback_test.go:432–468  ·  view source on GitHub ↗

Now test the upload being not cancelled by another upload being added because the upload hasn't started yet

(t *testing.T)

Source from the content-addressed store, hash-verified

430// Now test the upload being not cancelled by another upload being
431// added because the upload hasn't started yet
432func TestWriteBackAddUpdateNotStarted(t *testing.T) {
433 wb, cancel := newTestWriteBack(t)
434 defer cancel()
435
436 pi := newPutItem(t)
437
438 id := wb.Add(0, "one", 10, true, pi.put)
439 wbItem := wb.lookup[id]
440 checkOnHeap(t, wb, wbItem)
441 checkInLookup(t, wb, wbItem)
442 assert.Equal(t, "one", wb.string(t))
443
444 // Immediately add another upload before the first has started
445
446 pi2 := newPutItem(t)
447 id2 := wb.Add(id, "one", 10, true, pi2.put)
448 assert.Equal(t, id, id2)
449 checkOnHeap(t, wb, wbItem) // object still awaiting transfer
450 checkInLookup(t, wb, wbItem)
451
452 // Wait for the upload to start
453 <-pi2.started
454 checkNotOnHeap(t, wb, wbItem)
455 checkInLookup(t, wb, wbItem)
456
457 // Because modified was false above this should not cancel the
458 // transfer
459 assert.False(t, pi.cancelled)
460
461 // wait for new transfer to finish
462 pi2.finish(nil)
463 waitUntilNoTransfers(t, wb)
464 checkNotOnHeap(t, wb, wbItem)
465 checkNotInLookup(t, wb, wbItem)
466
467 assert.False(t, pi.called)
468}
469
470func TestWriteBackGetStats(t *testing.T) {
471 wb, cancel := newTestWriteBack(t)

Callers

nothing calls this directly

Calls 11

newTestWriteBackFunction · 0.85
newPutItemFunction · 0.85
checkOnHeapFunction · 0.85
checkInLookupFunction · 0.85
checkNotOnHeapFunction · 0.85
waitUntilNoTransfersFunction · 0.85
checkNotInLookupFunction · 0.85
AddMethod · 0.65
EqualMethod · 0.45
stringMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…