MCPcopy
hub / github.com/jackc/pgx / TestFatalTxError

Function TestFatalTxError

conn_test.go:876–905  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

874}
875
876func TestFatalTxError(t *testing.T) {
877 t.Parallel()
878
879 // Run timing sensitive test many times
880 for range 50 {
881 func() {
882 conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
883 defer closeConn(t, conn)
884
885 pgxtest.SkipCockroachDB(t, conn, "Server does not support pg_terminate_backend() (https://github.com/cockroachdb/cockroach/issues/35897)")
886
887 otherConn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
888 defer otherConn.Close(context.Background())
889
890 _, err := otherConn.Exec(context.Background(), "select pg_terminate_backend($1)", conn.PgConn().PID())
891 if err != nil {
892 t.Fatalf("Unable to kill backend PostgreSQL process: %v", err)
893 }
894
895 err = conn.QueryRow(context.Background(), "select 1").Scan(nil)
896 if err == nil {
897 t.Fatal("Expected error but none occurred")
898 }
899
900 if !conn.IsClosed() {
901 t.Fatalf("Connection should be closed but isn't. Previous Query err: %v", err)
902 }
903 }()
904 }
905}
906
907func TestInsertBoolArray(t *testing.T) {
908 t.Parallel()

Callers

nothing calls this directly

Calls 10

SkipCockroachDBFunction · 0.92
mustConnectStringFunction · 0.85
PIDMethod · 0.80
PgConnMethod · 0.80
closeConnFunction · 0.70
CloseMethod · 0.65
ExecMethod · 0.65
ScanMethod · 0.65
QueryRowMethod · 0.65
IsClosedMethod · 0.45

Tested by

no test coverage detected