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

Function TestEmptyQuery

db_test.go:130–156  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

128}
129
130func TestEmptyQuery(t *testing.T) {
131 db := pg.Connect(pgOptions())
132 defer db.Close()
133
134 assert := func(err error) {
135 if err == nil {
136 t.Fatal("error expected")
137 }
138 if err.Error() != "pg: query is empty" {
139 t.Fatal(err)
140 }
141 }
142
143 _, err := db.Exec("")
144 assert(err)
145
146 _, err = db.Query(pg.Discard, "")
147 assert(err)
148
149 stmt, err := db.Prepare("")
150 if err != nil {
151 t.Fatal(err)
152 }
153
154 _, err = stmt.Exec()
155 assert(err)
156}
157
158func TestAnonymousStructField(t *testing.T) {
159 type MyInt struct{ int }

Callers

nothing calls this directly

Calls 6

pgOptionsFunction · 0.85
CloseMethod · 0.65
ExecMethod · 0.65
QueryMethod · 0.65
ErrorMethod · 0.45
PrepareMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…