MCPcopy
hub / github.com/dnote/dnote / TestInitSystemKV

Function TestInitSystemKV

pkg/cli/infra/init_test.go:30–59  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28)
29
30func TestInitSystemKV(t *testing.T) {
31 // Setup
32 db := database.InitTestMemoryDB(t)
33
34 var originalCount int
35 database.MustScan(t, "counting system configs", db.QueryRow("SELECT count(*) FROM system"), &originalCount)
36
37 // Execute
38 tx, err := db.Begin()
39 if err != nil {
40 t.Fatal(errors.Wrap(err, "beginning a transaction"))
41 }
42
43 if err := initSystemKV(tx, "testKey", "testVal"); err != nil {
44 tx.Rollback()
45 t.Fatal(errors.Wrap(err, "executing"))
46 }
47
48 tx.Commit()
49
50 // Test
51 var count int
52 database.MustScan(t, "counting system configs", db.QueryRow("SELECT count(*) FROM system"), &count)
53 assert.Equal(t, count, originalCount+1, "system count mismatch")
54
55 var val string
56 database.MustScan(t, "getting system value",
57 db.QueryRow("SELECT value FROM system WHERE key = ?", "testKey"), &val)
58 assert.Equal(t, val, "testVal", "system value mismatch")
59}
60
61func TestInitSystemKV_existing(t *testing.T) {
62 // Setup

Callers

nothing calls this directly

Calls 8

InitTestMemoryDBFunction · 0.92
MustScanFunction · 0.92
EqualFunction · 0.92
initSystemKVFunction · 0.85
QueryRowMethod · 0.65
BeginMethod · 0.65
RollbackMethod · 0.65
CommitMethod · 0.65

Tested by

no test coverage detected