Test that updating a file removes its old blocks from the blockmap
(t *testing.T)
| 310 | |
| 311 | // Test that updating a file removes its old blocks from the blockmap |
| 312 | func TestCopierCleanup(t *testing.T) { |
| 313 | // Create a file |
| 314 | file := setupFile("test", []int{0}) |
| 315 | file.Size = 1 |
| 316 | m, f := setupSendReceiveFolder(t, file) |
| 317 | |
| 318 | file.Blocks = []protocol.BlockInfo{blocks[1]} |
| 319 | file.Version = file.Version.Update(myID.Short()) |
| 320 | // Update index (removing old blocks) |
| 321 | f.updateLocalsFromScanning([]protocol.FileInfo{file}) |
| 322 | |
| 323 | if vals, err := itererr.Collect(m.sdb.AllLocalBlocksWithHash(f.ID, blocks[0].Hash)); err != nil || len(vals) > 0 { |
| 324 | t.Error("Unexpected block found") |
| 325 | } |
| 326 | |
| 327 | if vals, err := itererr.Collect(m.sdb.AllLocalBlocksWithHash(f.ID, blocks[1].Hash)); err != nil || len(vals) == 0 { |
| 328 | t.Error("Expected block not found") |
| 329 | } |
| 330 | |
| 331 | file.Blocks = []protocol.BlockInfo{blocks[0]} |
| 332 | file.Version = file.Version.Update(myID.Short()) |
| 333 | // Update index (removing old blocks) |
| 334 | f.updateLocalsFromScanning([]protocol.FileInfo{file}) |
| 335 | |
| 336 | if vals, err := itererr.Collect(m.sdb.AllLocalBlocksWithHash(f.ID, blocks[0].Hash)); err != nil || len(vals) == 0 { |
| 337 | t.Error("Unexpected block found") |
| 338 | } |
| 339 | |
| 340 | if vals, err := itererr.Collect(m.sdb.AllLocalBlocksWithHash(f.ID, blocks[1].Hash)); err != nil || len(vals) > 0 { |
| 341 | t.Error("Expected block not found") |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | func TestDeregisterOnFailInCopy(t *testing.T) { |
| 346 | file := setupFile("filex", []int{0, 2, 0, 0, 5, 0, 0, 8}) |
nothing calls this directly
no test coverage detected