(t *testing.T)
| 355 | } |
| 356 | |
| 357 | func TestBeginReadOnly(t *testing.T) { |
| 358 | t.Parallel() |
| 359 | skipCockroachDB(t, "CockroachDB auto commits DDL by default") |
| 360 | |
| 361 | conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE")) |
| 362 | defer closeConn(t, conn) |
| 363 | |
| 364 | tx, err := conn.BeginTx(context.Background(), pgx.TxOptions{AccessMode: pgx.ReadOnly}) |
| 365 | if err != nil { |
| 366 | t.Fatalf("conn.Begin failed: %v", err) |
| 367 | } |
| 368 | defer tx.Rollback(context.Background()) |
| 369 | |
| 370 | _, err = conn.Exec(context.Background(), "create table foo(id serial primary key)") |
| 371 | if pgErr, ok := err.(*pgconn.PgError); !ok || pgErr.Code != "25006" { |
| 372 | t.Errorf("Expected error SQLSTATE 25006, but got %#v", err) |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | func TestBeginTxBeginQuery(t *testing.T) { |
| 377 | t.Parallel() |
nothing calls this directly
no test coverage detected