MCPcopy
hub / github.com/syncthing/syncthing / TestRecvOnlyDeletedRemoteDrop

Function TestRecvOnlyDeletedRemoteDrop

lib/model/folder_recvonly_test.go:271–334  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

269}
270
271func TestRecvOnlyDeletedRemoteDrop(t *testing.T) {
272 // Get us a model up and running
273
274 m, f, wcfgCancel := setupROFolder(t)
275 defer wcfgCancel()
276 ffs := f.Filesystem()
277 defer cleanupModel(m)
278 conn := addFakeConn(m, device1, f.ID)
279
280 // Create some test data
281
282 must(t, ffs.MkdirAll(".stfolder", 0o755))
283 oldData := []byte("hello\n")
284 knownFiles := setupKnownFiles(t, ffs, oldData)
285
286 // Send an index update for the known stuff
287
288 must(t, m.Index(conn, &protocol.Index{Folder: "ro", Files: knownFiles}))
289 f.updateLocalsFromScanning(knownFiles)
290
291 // Scan the folder.
292
293 must(t, m.ScanFolder("ro"))
294
295 // Everything should be in sync.
296
297 size := mustV(m.GlobalSize("ro"))
298 if size.Files != 1 || size.Directories != 1 {
299 t.Fatalf("Global: expected 1 file and 1 directory: %+v", size)
300 }
301 size = mustV(m.LocalSize("ro", protocol.LocalDeviceID))
302 if size.Files != 1 || size.Directories != 1 {
303 t.Fatalf("Local: expected 1 file and 1 directory: %+v", size)
304 }
305 size = mustV(m.NeedSize("ro", protocol.LocalDeviceID))
306 if size.Files+size.Directories > 0 {
307 t.Fatalf("Need: expected nothing: %+v", size)
308 }
309 size = mustV(m.ReceiveOnlySize("ro"))
310 if size.Files+size.Directories > 0 {
311 t.Fatalf("ROChanged: expected nothing: %+v", size)
312 }
313
314 // Delete our file
315
316 must(t, ffs.Remove(knownFiles[1].Name))
317
318 must(t, m.ScanFolder("ro"))
319
320 size = mustV(m.ReceiveOnlySize("ro"))
321 if size.Deleted != 1 {
322 t.Fatalf("Receive only: expected 1 deleted: %+v", size)
323 }
324
325 // Drop the remote
326
327 f.db.DropAllFiles("ro", device1)
328 must(t, m.ScanFolder("ro"))

Callers

nothing calls this directly

Calls 15

setupROFolderFunction · 0.85
cleanupModelFunction · 0.85
addFakeConnFunction · 0.85
mustFunction · 0.85
setupKnownFilesFunction · 0.85
mustVFunction · 0.85
FilesystemMethod · 0.80
MkdirAllMethod · 0.65
IndexMethod · 0.65
ScanFolderMethod · 0.65
GlobalSizeMethod · 0.65

Tested by

no test coverage detected