MCPcopy Index your code
hub / github.com/syncthing/syncthing / TestConcurrentUpdateSelect

Function TestConcurrentUpdateSelect

internal/db/sqlite/db_test.go:878–926  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

876}
877
878func TestConcurrentUpdateSelect(t *testing.T) {
879 t.Parallel()
880
881 db, err := Open(filepath.Join(t.TempDir(), "db"))
882 if err != nil {
883 t.Fatal(err)
884 }
885 t.Cleanup(func() {
886 if err := db.Close(); err != nil {
887 t.Fatal(err)
888 }
889 })
890
891 const folderID = "test"
892
893 // Some local files
894 files := []protocol.FileInfo{
895 genFile("test1", 1, 1),
896 genFile("test2", 2, 2),
897 genFile("test3", 3, 3),
898 genFile("test4", 4, 4),
899 }
900
901 // Insert the files for a remote device
902 if err := db.Update(folderID, protocol.DeviceID{42}, files); err != nil {
903 t.Fatal()
904 }
905
906 // Iterate over handled files and insert them for the local device.
907 // This is similar to a pattern we have in other places and should
908 // work.
909 handled := 0
910 it, errFn := db.AllNeededGlobalFiles(folderID, protocol.LocalDeviceID, config.PullOrderAlphabetic, 0, 0)
911 for glob := range it {
912 glob.Version = glob.Version.Update(1)
913 if err := db.Update(folderID, protocol.LocalDeviceID, []protocol.FileInfo{glob}); err != nil {
914 t.Fatal(err)
915 }
916 handled++
917 }
918 if err := errFn(); err != nil {
919 t.Fatal(err)
920 }
921
922 if handled != len(files) {
923 t.Log(handled)
924 t.Error("should have handled all the files")
925 }
926}
927
928func TestAllForBlocksHash(t *testing.T) {
929 t.Parallel()

Callers

nothing calls this directly

Calls 8

OpenFunction · 0.85
genFileFunction · 0.85
FatalMethod · 0.80
CloseMethod · 0.65
UpdateMethod · 0.65
AllNeededGlobalFilesMethod · 0.65
LogMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected