MCPcopy
hub / github.com/syncthing/syncthing / TestRequestDeleteChanged

Function TestRequestDeleteChanged

lib/model/requests_test.go:838–914  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

836}
837
838func TestRequestDeleteChanged(t *testing.T) {
839 m, fc, fcfg := setupModelWithConnection(t)
840 tfs := fcfg.Filesystem()
841 defer cleanupModelAndRemoveDir(m, tfs.URI())
842
843 done := make(chan struct{})
844 fc.setIndexFn(func(_ context.Context, folder string, fs []protocol.FileInfo) error {
845 select {
846 case <-done:
847 t.Error("More than one index update sent")
848 default:
849 }
850 close(done)
851 return nil
852 })
853
854 // setup
855 a := "a"
856 data := []byte("aData")
857 fc.addFile(a, 0o644, protocol.FileInfoTypeFile, data)
858 fc.sendIndexUpdate()
859 select {
860 case <-done:
861 done = make(chan struct{})
862 case <-time.After(10 * time.Second):
863 t.Fatal("timed out")
864 }
865
866 fc.setIndexFn(func(_ context.Context, folder string, fs []protocol.FileInfo) error {
867 select {
868 case <-done:
869 t.Error("More than one index update sent")
870 default:
871 }
872 close(done)
873 return nil
874 })
875
876 fd, err := tfs.OpenFile(a, fs.OptReadWrite, 0o644)
877 if err != nil {
878 t.Fatal(err)
879 }
880 otherData := []byte("otherData")
881 if _, err = fd.Write(otherData); err != nil {
882 t.Fatal(err)
883 }
884 fd.Close()
885
886 // rename
887 fc.deleteFile(a)
888 fc.sendIndexUpdate()
889 select {
890 case <-done:
891 case <-time.After(10 * time.Second):
892 t.Fatal("timed out")
893 }
894
895 // Check outcome. The file may have been moved to a conflict copy.

Callers

nothing calls this directly

Calls 14

setupModelWithConnectionFunction · 0.85
cleanupModelAndRemoveDirFunction · 0.85
FilesystemMethod · 0.80
setIndexFnMethod · 0.80
sendIndexUpdateMethod · 0.80
FatalMethod · 0.80
URIMethod · 0.65
ErrorMethod · 0.65
OpenFileMethod · 0.65
CloseMethod · 0.65
GlobMethod · 0.65
addFileMethod · 0.45

Tested by

no test coverage detected