MCPcopy
hub / github.com/syncthing/syncthing / TestBasics

Function TestBasics

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

Source from the content-addressed store, hash-verified

33)
34
35func TestBasics(t *testing.T) {
36 t.Parallel()
37
38 sdb, err := Open(t.TempDir())
39 if err != nil {
40 t.Fatal(err)
41 }
42 t.Cleanup(func() {
43 if err := sdb.Close(); err != nil {
44 t.Fatal(err)
45 }
46 })
47
48 // Some local files
49 local := []protocol.FileInfo{
50 genFile("test1", 1, 0),
51 genDir("test2", 0),
52 genFile("test2/a", 2, 0),
53 genFile("test2/b", 3, 0),
54 }
55 err = sdb.Update(folderID, protocol.LocalDeviceID, local)
56 if err != nil {
57 t.Fatal(err)
58 }
59
60 // Some remote files
61 remote := []protocol.FileInfo{
62 genFile("test3", 3, 101),
63 genFile("test4", 4, 102),
64 genFile("test1", 5, 103),
65 }
66 // All newer than the local ones
67 for i := range remote {
68 remote[i].Version = remote[i].Version.Update(42)
69 }
70 err = sdb.Update(folderID, protocol.DeviceID{42}, remote)
71 if err != nil {
72 t.Fatal(err)
73 }
74 const (
75 localSize = (1+2+3)*blockSize + dirSize
76 remoteSize = (3 + 4 + 5) * blockSize
77 globalSize = (2+3+3+4+5)*blockSize + dirSize
78 needSizeLocal = remoteSize
79 needSizeRemote = (2+3)*blockSize + dirSize
80 )
81
82 t.Run("SchemaVersion", func(t *testing.T) {
83 tx, err := sdb.sql.Beginx()
84 if err != nil {
85 t.Fatal(err)
86 }
87 defer tx.Rollback()
88 ver, err := sdb.getAppliedSchemaVersion(tx)
89 if err != nil {
90 t.Fatal(err)
91 }
92 if ver.SchemaVersion != currentSchemaVersion {

Callers

nothing calls this directly

Calls 15

OpenFunction · 0.85
genFileFunction · 0.85
genDirFunction · 0.85
fiNamesFunction · 0.85
FatalMethod · 0.80
RollbackMethod · 0.80
AppliedTimeMethod · 0.80
CloseMethod · 0.65
UpdateMethod · 0.65
LogMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected