MCPcopy
hub / github.com/rclone/rclone / TestWriteBackAddUpdate

Function TestWriteBackAddUpdate

vfs/vfscache/writeback/writeback_test.go:352–390  ·  view source on GitHub ↗

Now test the upload being cancelled by another upload being added

(t *testing.T)

Source from the content-addressed store, hash-verified

350
351// Now test the upload being cancelled by another upload being added
352func TestWriteBackAddUpdate(t *testing.T) {
353 wb, cancel := newTestWriteBack(t)
354 defer cancel()
355
356 pi := newPutItem(t)
357
358 id := wb.Add(0, "one", 10, true, pi.put)
359 wbItem := wb.lookup[id]
360 assert.Equal(t, int64(10), wbItem.size) // check size
361 checkOnHeap(t, wb, wbItem)
362 checkInLookup(t, wb, wbItem)
363 assert.Equal(t, "one", wb.string(t))
364
365 <-pi.started
366 checkNotOnHeap(t, wb, wbItem)
367 checkInLookup(t, wb, wbItem)
368
369 // Now the upload has started add another one
370
371 pi2 := newPutItem(t)
372 id2 := wb.Add(id, "one", 20, true, pi2.put)
373 assert.Equal(t, id, id2)
374 assert.Equal(t, int64(20), wbItem.size) // check size has changed
375 checkOnHeap(t, wb, wbItem) // object awaiting writeback time
376 checkInLookup(t, wb, wbItem)
377
378 // check the previous transfer was cancelled
379 assert.True(t, pi.cancelled)
380
381 // check the retry
382 <-pi2.started
383 checkNotOnHeap(t, wb, wbItem)
384 checkInLookup(t, wb, wbItem)
385
386 pi2.finish(nil) // transfer successful
387 waitUntilNoTransfers(t, wb)
388 checkNotOnHeap(t, wb, wbItem)
389 checkNotInLookup(t, wb, wbItem)
390}
391
392// Now test the upload being not cancelled by another upload being added
393func TestWriteBackAddUpdateNotModified(t *testing.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…