MCPcopy
hub / github.com/Masterminds/squirrel / TestStmtCachePrepare

Function TestStmtCachePrepare

stmtcacher_test.go:9–26  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestStmtCachePrepare(t *testing.T) {
10 db := &DBStub{}
11 sc := NewStmtCache(db)
12 query := "SELECT 1"
13
14 sc.Prepare(query)
15 assert.Equal(t, query, db.LastPrepareSql)
16
17 sc.Prepare(query)
18 assert.Equal(t, 1, db.PrepareCount, "expected 1 Prepare, got %d", db.PrepareCount)
19
20 // clear statement cache
21 assert.Nil(t, sc.Clear())
22
23 // should prepare the query again
24 sc.Prepare(query)
25 assert.Equal(t, 2, db.PrepareCount, "expected 2 Prepare, got %d", db.PrepareCount)
26}

Callers

nothing calls this directly

Calls 3

PrepareMethod · 0.95
ClearMethod · 0.95
NewStmtCacheFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…