MCPcopy
hub / github.com/syncthing/syncthing / TestScanDeletedROChangedOnSR

Function TestScanDeletedROChangedOnSR

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

Source from the content-addressed store, hash-verified

3612}
3613
3614func TestScanDeletedROChangedOnSR(t *testing.T) {
3615 m, conn, fcfg := setupModelWithConnection(t)
3616 ffs := fcfg.Filesystem()
3617 defer cleanupModelAndRemoveDir(m, ffs.URI())
3618 fcfg.Type = config.FolderTypeReceiveOnly
3619 setFolder(t, m.cfg, fcfg)
3620
3621 name := "foo"
3622
3623 writeFile(t, ffs, name, []byte(name))
3624 m.ScanFolders()
3625
3626 file, ok := m.testCurrentFolderFile(fcfg.ID, name)
3627 if !ok {
3628 t.Fatal("file missing in db")
3629 }
3630 // A remote must have the file, otherwise the deletion below is
3631 // automatically resolved as not a ro-changed item.
3632 file.LocalFlags = 0 // clear as we're skipping the code path where it would otherwise be cleared naturally
3633 must(t, m.IndexUpdate(conn, &protocol.IndexUpdate{Folder: fcfg.ID, Files: []protocol.FileInfo{file}}))
3634
3635 must(t, ffs.Remove(name))
3636 m.ScanFolders()
3637
3638 if mustV(m.ReceiveOnlySize(fcfg.ID)).Deleted != 1 {
3639 t.Fatal("expected one receive only changed deleted item")
3640 }
3641
3642 fcfg.Type = config.FolderTypeSendReceive
3643 setFolder(t, m.cfg, fcfg)
3644 m.ScanFolders()
3645
3646 if mustV(m.ReceiveOnlySize(fcfg.ID)).Deleted != 0 {
3647 t.Fatal("expected no receive only changed deleted item")
3648 }
3649 if mustV(m.LocalSize(fcfg.ID, protocol.LocalDeviceID)).Deleted != 1 {
3650 t.Fatal("expected one local deleted item")
3651 }
3652}
3653
3654func testConfigChangeTriggersClusterConfigs(t *testing.T, expectFirst, expectSecond bool, pre func(config.Wrapper), fn func(config.Wrapper)) {
3655 t.Helper()

Callers

nothing calls this directly

Calls 15

setupModelWithConnectionFunction · 0.85
cleanupModelAndRemoveDirFunction · 0.85
setFolderFunction · 0.85
mustFunction · 0.85
mustVFunction · 0.85
FilesystemMethod · 0.80
testCurrentFolderFileMethod · 0.80
FatalMethod · 0.80
writeFileFunction · 0.70
URIMethod · 0.65
ScanFoldersMethod · 0.65
IndexUpdateMethod · 0.65

Tested by

no test coverage detected