(t *testing.T)
| 27 | ) |
| 28 | |
| 29 | func TestInsertSystem(t *testing.T) { |
| 30 | testCases := []struct { |
| 31 | key string |
| 32 | val string |
| 33 | }{ |
| 34 | { |
| 35 | key: "foo", |
| 36 | val: "1558089284", |
| 37 | }, |
| 38 | { |
| 39 | key: "baz", |
| 40 | val: "quz", |
| 41 | }, |
| 42 | } |
| 43 | |
| 44 | for _, tc := range testCases { |
| 45 | t.Run(fmt.Sprintf("insert %s %s", tc.key, tc.val), func(t *testing.T) { |
| 46 | // Setup |
| 47 | db := InitTestMemoryDB(t) |
| 48 | |
| 49 | // execute |
| 50 | tx, err := db.Begin() |
| 51 | if err != nil { |
| 52 | t.Fatal(errors.Wrap(err, "beginning a transaction").Error()) |
| 53 | } |
| 54 | |
| 55 | if err := InsertSystem(tx, tc.key, tc.val); err != nil { |
| 56 | tx.Rollback() |
| 57 | t.Fatal(errors.Wrap(err, "executing for test case").Error()) |
| 58 | } |
| 59 | |
| 60 | tx.Commit() |
| 61 | |
| 62 | // test |
| 63 | var key, val string |
| 64 | MustScan(t, "getting the saved record", |
| 65 | db.QueryRow("SELECT key, value FROM system WHERE key = ?", tc.key), &key, &val) |
| 66 | |
| 67 | assert.Equal(t, key, tc.key, "key mismatch for test case") |
| 68 | assert.Equal(t, val, tc.val, "val mismatch for test case") |
| 69 | }) |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | func TestUpsertSystem(t *testing.T) { |
| 74 | testCases := []struct { |
nothing calls this directly
no test coverage detected