Now test the upload being cancelled by another upload being added
(t *testing.T)
| 350 | |
| 351 | // Now test the upload being cancelled by another upload being added |
| 352 | func 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 |
| 393 | func TestWriteBackAddUpdateNotModified(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…