MCPcopy Create free account
hub / github.com/go-pg/pg / TestClosedTx

Method TestClosedTx

pool_test.go:115–134  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

113}
114
115func (t *PoolTest) TestClosedTx(c *C) {
116 tx, err := t.db.Begin()
117 c.Assert(err, IsNil)
118
119 c.Assert(t.db.Pool().Len(), Equals, 1)
120 c.Assert(t.db.Pool().IdleLen(), Equals, 0)
121
122 c.Assert(tx.Rollback(), IsNil)
123
124 c.Assert(t.db.Pool().Len(), Equals, 1)
125 c.Assert(t.db.Pool().IdleLen(), Equals, 1)
126
127 err = tx.Rollback()
128 c.Assert(err, Not(IsNil))
129 c.Assert(err.Error(), Equals, "pg: transaction has already been committed or rolled back")
130
131 _, err = tx.Exec("SELECT 'test_closed_tx'")
132 c.Assert(err, Not(IsNil))
133 c.Assert(err.Error(), Equals, "pg: transaction has already been committed or rolled back")
134}
135
136func (t *PoolTest) TestClosedStmt(c *C) {
137 stmt, err := t.db.Prepare("SELECT $1::int")

Callers

nothing calls this directly

Calls 8

AssertMethod · 0.80
PoolMethod · 0.80
RollbackMethod · 0.80
BeginMethod · 0.65
LenMethod · 0.65
IdleLenMethod · 0.65
ExecMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected