MCPcopy
hub / github.com/syncthing/syncthing / TestIssue3028

Function TestIssue3028

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

Source from the content-addressed store, hash-verified

2092}
2093
2094func TestIssue3028(t *testing.T) {
2095 w, cancel := newConfigWrapper(defaultCfg)
2096 defer cancel()
2097 ffs := w.FolderList()[0].Filesystem()
2098 m := setupModel(t, w)
2099 defer cleanupModel(m)
2100
2101 // Create two files that we'll delete, one with a name that is a prefix of the other.
2102
2103 writeFile(t, ffs, "testrm", []byte("Hello"))
2104 writeFile(t, ffs, "testrm2", []byte("Hello"))
2105
2106 // Scan, and get a count of how many files are there now
2107
2108 m.ScanFolderSubdirs("default", []string{"testrm", "testrm2"})
2109 locorigfiles := mustV(m.LocalSize("default", protocol.LocalDeviceID)).Files
2110 globorigfiles := mustV(m.GlobalSize("default")).Files
2111
2112 // Delete
2113
2114 must(t, ffs.Remove("testrm"))
2115 must(t, ffs.Remove("testrm2"))
2116
2117 // Verify that the number of files decreased by two and the number of
2118 // deleted files increases by two
2119
2120 m.ScanFolderSubdirs("default", []string{"testrm", "testrm2"})
2121 loc := mustV(m.LocalSize("default", protocol.LocalDeviceID))
2122 glob := mustV(m.GlobalSize("default"))
2123
2124 if loc.Files != locorigfiles-2 {
2125 t.Errorf("Incorrect local accounting; got %d current files, expected %d", loc.Files, locorigfiles-2)
2126 }
2127 if glob.Files != globorigfiles-2 {
2128 t.Errorf("Incorrect global accounting; got %d current files, expected %d", glob.Files, globorigfiles-2)
2129 }
2130 if loc.Deleted != 2 {
2131 t.Errorf("Incorrect local accounting; got %d deleted files, expected 2", loc.Deleted)
2132 }
2133 if glob.Deleted != 2 {
2134 t.Errorf("Incorrect global accounting; got %d deleted files, expected 2", glob.Deleted)
2135 }
2136}
2137
2138func TestIssue4357(t *testing.T) {
2139 cfg := defaultCfgWrapper.RawCopy()

Callers

nothing calls this directly

Calls 12

newConfigWrapperFunction · 0.85
setupModelFunction · 0.85
cleanupModelFunction · 0.85
mustVFunction · 0.85
mustFunction · 0.85
FilesystemMethod · 0.80
writeFileFunction · 0.70
FolderListMethod · 0.65
ScanFolderSubdirsMethod · 0.65
LocalSizeMethod · 0.65
GlobalSizeMethod · 0.65
RemoveMethod · 0.65

Tested by

no test coverage detected