MCPcopy
hub / github.com/syncthing/syncthing / TestScanRenameCaseOnly

Function TestScanRenameCaseOnly

lib/model/model_test.go:3494–3542  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3492}
3493
3494func TestScanRenameCaseOnly(t *testing.T) {
3495 wcfg, fcfg := newDefaultCfgWrapper(t)
3496 m := setupModel(t, wcfg)
3497 defer cleanupModel(m)
3498
3499 ffs := fcfg.Filesystem()
3500 name := "foo"
3501 writeFile(t, ffs, name, []byte("contents"))
3502
3503 m.ScanFolders()
3504
3505 found := false
3506 for i, err := range itererr.Zip(m.LocalFiles(fcfg.ID, protocol.LocalDeviceID)) {
3507 if err != nil {
3508 t.Fatal(err)
3509 }
3510 if found {
3511 t.Fatal("got more than one file")
3512 }
3513 if i.FileName() != name {
3514 t.Fatalf("got file %v, expected %v", i.FileName(), name)
3515 }
3516 found = true
3517 }
3518
3519 upper := strings.ToUpper(name)
3520 must(t, ffs.Rename(name, upper))
3521 m.ScanFolders()
3522
3523 found = false
3524 for i, err := range itererr.Zip(m.LocalFiles(fcfg.ID, protocol.LocalDeviceID)) {
3525 if err != nil {
3526 t.Fatal(err)
3527 }
3528 if i.FileName() == name {
3529 if i.IsDeleted() {
3530 continue
3531 }
3532 t.Fatal("renamed file not deleted")
3533 }
3534 if i.FileName() != upper {
3535 t.Fatalf("got file %v, expected %v", i.FileName(), upper)
3536 }
3537 if found {
3538 t.Fatal("got more than the expected files")
3539 }
3540 found = true
3541 }
3542}
3543
3544func TestClusterConfigOnFolderAdd(t *testing.T) {
3545 testConfigChangeTriggersClusterConfigs(t, false, true, nil, func(wrapper config.Wrapper) {

Callers

nothing calls this directly

Calls 13

ZipFunction · 0.92
newDefaultCfgWrapperFunction · 0.85
setupModelFunction · 0.85
cleanupModelFunction · 0.85
mustFunction · 0.85
FilesystemMethod · 0.80
FatalMethod · 0.80
FileNameMethod · 0.80
IsDeletedMethod · 0.80
writeFileFunction · 0.70
ScanFoldersMethod · 0.65
LocalFilesMethod · 0.65

Tested by

no test coverage detected