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

Method TestLoaderError

loader_test.go:142–158  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

140}
141
142func (t *LoaderTest) TestLoaderError(c *C) {
143 tx, err := t.db.Begin()
144 c.Assert(err, IsNil)
145 defer tx.Rollback()
146
147 loader := newErrLoader(errors.New("my error"))
148 _, err = tx.QueryOne(loader, "SELECT 1, 2")
149 c.Assert(err, Not(IsNil))
150 c.Assert(err.Error(), Equals, "my error")
151
152 // Verify that client is still functional.
153 var n1, n2 int
154 _, err = tx.QueryOne(pg.Scan(&n1, &n2), "SELECT 1, 2")
155 c.Assert(err, IsNil)
156 c.Assert(n1, Equals, 1)
157 c.Assert(n2, Equals, 2)
158}

Callers

nothing calls this directly

Calls 8

newErrLoaderFunction · 0.85
AssertMethod · 0.80
RollbackMethod · 0.80
BeginMethod · 0.65
QueryOneMethod · 0.65
NewMethod · 0.45
ErrorMethod · 0.45
ScanMethod · 0.45

Tested by

no test coverage detected