MCPcopy
hub / github.com/syncthing/syncthing / TestNeedMetaAfterIndexReset

Function TestNeedMetaAfterIndexReset

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

Source from the content-addressed store, hash-verified

3801}
3802
3803func TestNeedMetaAfterIndexReset(t *testing.T) {
3804 w, fcfg := newDefaultCfgWrapper(t)
3805 addDevice2(t, w, fcfg)
3806 m := setupModel(t, w)
3807 defer cleanupModelAndRemoveDir(m, fcfg.Path)
3808 conn1 := addFakeConn(m, device1, fcfg.ID)
3809 conn2 := addFakeConn(m, device2, fcfg.ID)
3810
3811 var seq int64 = 1
3812 files := []protocol.FileInfo{{Name: "foo", Size: 10, Version: protocol.Vector{}.Update(device1.Short()), Sequence: seq}}
3813
3814 // Start with two remotes having one file, then both deleting it, then
3815 // only one adding it again.
3816 must(t, m.Index(conn1, &protocol.Index{Folder: fcfg.ID, Files: files}))
3817 must(t, m.Index(conn2, &protocol.Index{Folder: fcfg.ID, Files: files}))
3818 seq++
3819 files[0].SetDeleted(device2.Short())
3820 files[0].Sequence = seq
3821 must(t, m.IndexUpdate(conn1, &protocol.IndexUpdate{Folder: fcfg.ID, Files: files}))
3822 must(t, m.IndexUpdate(conn2, &protocol.IndexUpdate{Folder: fcfg.ID, Files: files}))
3823 seq++
3824 files[0].Deleted = false
3825 files[0].Size = 20
3826 files[0].Version = files[0].Version.Update(device1.Short())
3827 files[0].Sequence = seq
3828 must(t, m.IndexUpdate(conn1, &protocol.IndexUpdate{Folder: fcfg.ID, Files: files}))
3829
3830 if comp := m.testCompletion(device2, fcfg.ID); comp.NeedItems != 1 {
3831 t.Error("Expected one needed item for device2, got", comp.NeedItems)
3832 }
3833
3834 // Pretend we had an index reset on device 1
3835 must(t, m.Index(conn1, &protocol.Index{Folder: fcfg.ID, Files: files}))
3836 if comp := m.testCompletion(device2, fcfg.ID); comp.NeedItems != 1 {
3837 t.Error("Expected one needed item for device2, got", comp.NeedItems)
3838 }
3839}
3840
3841func TestCcCheckEncryption(t *testing.T) {
3842 if testing.Short() {

Callers

nothing calls this directly

Calls 13

newDefaultCfgWrapperFunction · 0.85
addDevice2Function · 0.85
setupModelFunction · 0.85
cleanupModelAndRemoveDirFunction · 0.85
addFakeConnFunction · 0.85
mustFunction · 0.85
ShortMethod · 0.80
SetDeletedMethod · 0.80
testCompletionMethod · 0.80
UpdateMethod · 0.65
IndexMethod · 0.65
IndexUpdateMethod · 0.65

Tested by

no test coverage detected