(t *testing.T)
| 334 | } |
| 335 | |
| 336 | func TestRecvOnlyRemoteUndoChanges(t *testing.T) { |
| 337 | // Get us a model up and running |
| 338 | |
| 339 | m, f, wcfgCancel := setupROFolder(t) |
| 340 | defer wcfgCancel() |
| 341 | ffs := f.Filesystem() |
| 342 | defer cleanupModel(m) |
| 343 | conn := addFakeConn(m, device1, f.ID) |
| 344 | |
| 345 | // Create some test data |
| 346 | |
| 347 | must(t, ffs.MkdirAll(".stfolder", 0o755)) |
| 348 | oldData := []byte("hello\n") |
| 349 | knownFiles := setupKnownFiles(t, ffs, oldData) |
| 350 | |
| 351 | // Send an index update for the known stuff |
| 352 | |
| 353 | must(t, m.Index(conn, &protocol.Index{Folder: "ro", Files: knownFiles})) |
| 354 | f.updateLocalsFromScanning(knownFiles) |
| 355 | |
| 356 | // Scan the folder. |
| 357 | |
| 358 | must(t, m.ScanFolder("ro")) |
| 359 | |
| 360 | // Everything should be in sync. |
| 361 | |
| 362 | size := mustV(m.GlobalSize("ro")) |
| 363 | if size.Files != 1 || size.Directories != 1 { |
| 364 | t.Fatalf("Global: expected 1 file and 1 directory: %+v", size) |
| 365 | } |
| 366 | size = mustV(m.LocalSize("ro", protocol.LocalDeviceID)) |
| 367 | if size.Files != 1 || size.Directories != 1 { |
| 368 | t.Fatalf("Local: expected 1 file and 1 directory: %+v", size) |
| 369 | } |
| 370 | size = mustV(m.NeedSize("ro", protocol.LocalDeviceID)) |
| 371 | if size.Files+size.Directories > 0 { |
| 372 | t.Fatalf("Need: expected nothing: %+v", size) |
| 373 | } |
| 374 | size = mustV(m.ReceiveOnlySize("ro")) |
| 375 | if size.Files+size.Directories > 0 { |
| 376 | t.Fatalf("ROChanged: expected nothing: %+v", size) |
| 377 | } |
| 378 | |
| 379 | // Create a file and modify another |
| 380 | |
| 381 | const file = "foo" |
| 382 | knownFile := filepath.Join("knownDir", "knownFile") |
| 383 | writeFilePerm(t, ffs, file, []byte("hello\n"), 0o644) |
| 384 | writeFilePerm(t, ffs, knownFile, []byte("bye\n"), 0o644) |
| 385 | |
| 386 | must(t, m.ScanFolder("ro")) |
| 387 | |
| 388 | size = mustV(m.ReceiveOnlySize("ro")) |
| 389 | if size.Files != 2 { |
| 390 | t.Fatalf("Receive only: expected 2 files: %+v", size) |
| 391 | } |
| 392 | |
| 393 | // Do the same changes on the remote |
nothing calls this directly
no test coverage detected