(t *testing.T)
| 28 | ) |
| 29 | |
| 30 | func 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 | |
| 61 | func TestInitSystemKV_existing(t *testing.T) { |
| 62 | // Setup |
nothing calls this directly
no test coverage detected