(t *testing.T)
| 218 | } |
| 219 | |
| 220 | func TestExec(t *testing.T) { |
| 221 | t.Parallel() |
| 222 | |
| 223 | ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) |
| 224 | defer cancel() |
| 225 | |
| 226 | pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) { |
| 227 | if results := mustExec(t, conn, "create temporary table foo(id integer primary key);"); results.String() != "CREATE TABLE" { |
| 228 | t.Error("Unexpected results from Exec") |
| 229 | } |
| 230 | |
| 231 | // Accept parameters |
| 232 | if results := mustExec(t, conn, "insert into foo(id) values($1)", 1); results.String() != "INSERT 0 1" { |
| 233 | t.Errorf("Unexpected results from Exec: %v", results) |
| 234 | } |
| 235 | |
| 236 | if results := mustExec(t, conn, "drop table foo;"); results.String() != "DROP TABLE" { |
| 237 | t.Error("Unexpected results from Exec") |
| 238 | } |
| 239 | |
| 240 | // Multiple statements can be executed -- last command tag is returned |
| 241 | if results := mustExec(t, conn, "create temporary table foo(id serial primary key); drop table foo;"); results.String() != "DROP TABLE" { |
| 242 | t.Error("Unexpected results from Exec") |
| 243 | } |
| 244 | |
| 245 | // Can execute longer SQL strings than sharedBufferSize |
| 246 | if results := mustExec(t, conn, strings.Repeat("select 42; ", 1000)); results.String() != "SELECT 1" { |
| 247 | t.Errorf("Unexpected results from Exec: %v", results) |
| 248 | } |
| 249 | |
| 250 | // Exec no-op which does not return a command tag |
| 251 | if results := mustExec(t, conn, "--;"); results.String() != "" { |
| 252 | t.Errorf("Unexpected results from Exec: %v", results) |
| 253 | } |
| 254 | }) |
| 255 | } |
| 256 | |
| 257 | type testQueryRewriter struct { |
| 258 | sql string |
nothing calls this directly
no test coverage detected