chore: add tests & refactor (#1346)

* chore: add tests & refactor

* chore: refactor
This commit is contained in:
Kevin Wan
2021-12-18 23:11:38 +08:00
committed by GitHub
parent 3e6c217408
commit d1c2a31af7
3 changed files with 27 additions and 30 deletions

View File

@@ -562,6 +562,18 @@ func TestQueryRowNoCache(t *testing.T) {
assert.True(t, ran)
}
func TestNewConnWithCache(t *testing.T) {
r, clean, err := redistest.CreateRedis()
assert.Nil(t, err)
defer clean()
var conn trackedConn
c := NewConnWithCache(&conn, cache.NewNode(r, exclusiveCalls, stats, sql.ErrNoRows))
_, err = c.ExecNoCache("delete from user_table where id='kevin'")
assert.Nil(t, err)
assert.True(t, conn.execValue)
}
func resetStats() {
atomic.StoreUint64(&stats.Total, 0)
atomic.StoreUint64(&stats.Hit, 0)