MCPcopy
hub / github.com/safing/portmaster / TestSQLite

Function TestSQLite

base/database/storage/sqlite/sqlite_test.go:41–216  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

39}
40
41func TestSQLite(t *testing.T) {
42 t.Parallel()
43
44 // start
45 testDir := t.TempDir()
46 db, err := openSQLite("test", testDir, true)
47 if err != nil {
48 t.Fatal(err)
49 }
50 defer func() {
51 // shutdown
52 err = db.Shutdown()
53 if err != nil {
54 t.Fatal(err)
55 }
56 }()
57
58 a := &TestRecord{
59 S: "banana",
60 I: 42,
61 I8: 42,
62 I16: 42,
63 I32: 42,
64 I64: 42,
65 UI: 42,
66 UI8: 42,
67 UI16: 42,
68 UI32: 42,
69 UI64: 42,
70 F32: 42.42,
71 F64: 42.42,
72 B: true,
73 }
74 a.SetMeta(&record.Meta{})
75 a.Meta().Update()
76 a.SetKey("test:A")
77
78 // put record
79 _, err = db.Put(a)
80 if err != nil {
81 t.Fatal(err)
82 }
83
84 // get and compare
85 r1, err := db.Get("A")
86 if err != nil {
87 t.Fatal(err)
88 }
89
90 a1 := &TestRecord{}
91 err = record.Unwrap(r1, a1)
92 if err != nil {
93 t.Fatal(err)
94 }
95 assert.Equal(t, a, a1, "struct must match")
96
97 // setup query test records
98 qA := &TestRecord{}

Callers

nothing calls this directly

Calls 15

UnwrapFunction · 0.92
NewFunction · 0.92
openSQLiteFunction · 0.85
MustBeValidMethod · 0.80
ErrMethod · 0.80
ShutdownMethod · 0.65
SetMetaMethod · 0.65
MetaMethod · 0.65
SetKeyMethod · 0.65
PutMethod · 0.65
GetMethod · 0.65
UpdateMetaMethod · 0.65

Tested by

no test coverage detected