(t *testing.T)
| 3300 | } |
| 3301 | |
| 3302 | func TestRenameSameFile(t *testing.T) { |
| 3303 | wcfg, fcfg := newDefaultCfgWrapper(t) |
| 3304 | m := setupModel(t, wcfg) |
| 3305 | defer cleanupModel(m) |
| 3306 | |
| 3307 | ffs := fcfg.Filesystem() |
| 3308 | writeFile(t, ffs, "file", []byte("file")) |
| 3309 | |
| 3310 | m.ScanFolders() |
| 3311 | |
| 3312 | count := countIterator[protocol.FileInfo](t)(m.LocalFiles("default", protocol.LocalDeviceID)) |
| 3313 | if count != 1 { |
| 3314 | t.Errorf("Unexpected count: %d != %d", count, 1) |
| 3315 | } |
| 3316 | |
| 3317 | must(t, ffs.Rename("file", "file1")) |
| 3318 | must(t, osutil.Copy(fs.CopyRangeMethodStandard, ffs, ffs, "file1", "file0")) |
| 3319 | must(t, osutil.Copy(fs.CopyRangeMethodStandard, ffs, ffs, "file1", "file2")) |
| 3320 | must(t, osutil.Copy(fs.CopyRangeMethodStandard, ffs, ffs, "file1", "file3")) |
| 3321 | must(t, osutil.Copy(fs.CopyRangeMethodStandard, ffs, ffs, "file1", "file4")) |
| 3322 | |
| 3323 | m.ScanFolders() |
| 3324 | |
| 3325 | prevSeq := int64(0) |
| 3326 | seen := false |
| 3327 | it, errFn := m.LocalFilesSequenced("default", protocol.LocalDeviceID, 0) |
| 3328 | for i := range it { |
| 3329 | if i.SequenceNo() <= prevSeq { |
| 3330 | t.Fatalf("non-increasing sequences: %d <= %d", i.SequenceNo(), prevSeq) |
| 3331 | } |
| 3332 | if i.FileName() == "file" { |
| 3333 | if seen { |
| 3334 | t.Fatal("already seen file") |
| 3335 | } |
| 3336 | seen = true |
| 3337 | } |
| 3338 | prevSeq = i.SequenceNo() |
| 3339 | } |
| 3340 | if err := errFn(); err != nil { |
| 3341 | t.Fatal(err) |
| 3342 | } |
| 3343 | } |
| 3344 | |
| 3345 | // TestRenameBatchFlush verifies that rename detection works correctly when |
| 3346 | // a batch flush happens mid-scan. With enough files to exceed |
nothing calls this directly
no test coverage detected