Extract SkipCockroachDB to pgxtest
This commit is contained in:
+4
-4
@@ -17,7 +17,7 @@ func TestConnSendBatch(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||
skipCockroachDB(t, conn, "Server serial type is incompatible with test")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server serial type is incompatible with test")
|
||||
|
||||
sql := `create temporary table ledger(
|
||||
id serial primary key,
|
||||
@@ -196,7 +196,7 @@ func TestConnSendBatchWithPreparedStatement(t *testing.T) {
|
||||
// Don't test simple mode with prepared statements.
|
||||
}
|
||||
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, modes, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||
skipCockroachDB(t, conn, "Server issues incorrect ParameterDescription (https://github.com/cockroachdb/cockroach/issues/60907)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server issues incorrect ParameterDescription (https://github.com/cockroachdb/cockroach/issues/60907)")
|
||||
_, err := conn.Prepare(context.Background(), "ps1", "select n from generate_series(0,$1::int) n")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -253,7 +253,7 @@ func TestConnSendBatchWithPreparedStatementAndStatementCacheDisabled(t *testing.
|
||||
conn := mustConnect(t, config)
|
||||
defer closeConn(t, conn)
|
||||
|
||||
skipCockroachDB(t, conn, "Server issues incorrect ParameterDescription (https://github.com/cockroachdb/cockroach/issues/60907)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server issues incorrect ParameterDescription (https://github.com/cockroachdb/cockroach/issues/60907)")
|
||||
|
||||
_, err = conn.Prepare(context.Background(), "ps1", "select n from generate_series(0,$1::int) n")
|
||||
if err != nil {
|
||||
@@ -600,7 +600,7 @@ func TestConnBeginBatchDeferredError(t *testing.T) {
|
||||
|
||||
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||
|
||||
skipCockroachDB(t, conn, "Server does not support deferred constraint (https://github.com/cockroachdb/cockroach/issues/31632)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does not support deferred constraint (https://github.com/cockroachdb/cockroach/issues/31632)")
|
||||
|
||||
mustExec(t, conn, `create temporary table t (
|
||||
id text primary key,
|
||||
|
||||
+6
-6
@@ -506,7 +506,7 @@ func TestListenNotifyWhileBusyIsSafe(t *testing.T) {
|
||||
func() {
|
||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer closeConn(t, conn)
|
||||
skipCockroachDB(t, conn, "Server does not support LISTEN / NOTIFY (https://github.com/cockroachdb/cockroach/issues/41522)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does not support LISTEN / NOTIFY (https://github.com/cockroachdb/cockroach/issues/41522)")
|
||||
}()
|
||||
|
||||
listenerDone := make(chan bool)
|
||||
@@ -582,7 +582,7 @@ func TestListenNotifySelfNotification(t *testing.T) {
|
||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer closeConn(t, conn)
|
||||
|
||||
skipCockroachDB(t, conn, "Server does not support LISTEN / NOTIFY (https://github.com/cockroachdb/cockroach/issues/41522)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does not support LISTEN / NOTIFY (https://github.com/cockroachdb/cockroach/issues/41522)")
|
||||
|
||||
mustExec(t, conn, "listen self")
|
||||
|
||||
@@ -617,7 +617,7 @@ func TestFatalRxError(t *testing.T) {
|
||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer closeConn(t, conn)
|
||||
|
||||
skipCockroachDB(t, conn, "Server does not support pg_terminate_backend() (https://github.com/cockroachdb/cockroach/issues/35897)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does not support pg_terminate_backend() (https://github.com/cockroachdb/cockroach/issues/35897)")
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
@@ -656,7 +656,7 @@ func TestFatalTxError(t *testing.T) {
|
||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer closeConn(t, conn)
|
||||
|
||||
skipCockroachDB(t, conn, "Server does not support pg_terminate_backend() (https://github.com/cockroachdb/cockroach/issues/35897)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does not support pg_terminate_backend() (https://github.com/cockroachdb/cockroach/issues/35897)")
|
||||
|
||||
otherConn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer otherConn.Close(context.Background())
|
||||
@@ -821,7 +821,7 @@ func TestConnInitTypeMap(t *testing.T) {
|
||||
|
||||
func TestUnregisteredTypeUsableAsStringArgumentAndBaseResult(t *testing.T) {
|
||||
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||
skipCockroachDB(t, conn, "Server does support domain types (https://github.com/cockroachdb/cockroach/issues/27796)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does support domain types (https://github.com/cockroachdb/cockroach/issues/27796)")
|
||||
|
||||
var n uint64
|
||||
err := conn.QueryRow(context.Background(), "select $1::uint64", "42").Scan(&n)
|
||||
@@ -837,7 +837,7 @@ func TestUnregisteredTypeUsableAsStringArgumentAndBaseResult(t *testing.T) {
|
||||
|
||||
func TestDomainType(t *testing.T) {
|
||||
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||
skipCockroachDB(t, conn, "Server does support domain types (https://github.com/cockroachdb/cockroach/issues/27796)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does support domain types (https://github.com/cockroachdb/cockroach/issues/27796)")
|
||||
|
||||
// Domain type uint64 is a PostgreSQL domain of underlying type numeric.
|
||||
|
||||
|
||||
+3
-2
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/jackc/pgx/v5/pgxtest"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -134,7 +135,7 @@ func TestConnCopyFromLarge(t *testing.T) {
|
||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer closeConn(t, conn)
|
||||
|
||||
skipCockroachDB(t, conn, "Skipping due to known server issue: (https://github.com/cockroachdb/cockroach/issues/52722)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Skipping due to known server issue: (https://github.com/cockroachdb/cockroach/issues/52722)")
|
||||
|
||||
mustExec(t, conn, `create temporary table foo(
|
||||
a int2,
|
||||
@@ -416,7 +417,7 @@ func TestConnCopyFromFailServerSideMidwayAbortsWithoutWaiting(t *testing.T) {
|
||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer closeConn(t, conn)
|
||||
|
||||
skipCockroachDB(t, conn, "Server copy error does not fail fast")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server copy error does not fail fast")
|
||||
|
||||
mustExec(t, conn, `create temporary table foo(
|
||||
a bytea not null
|
||||
|
||||
@@ -137,9 +137,3 @@ func assertConfigsEqual(t *testing.T, expected, actual *pgx.ConnConfig, testName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func skipCockroachDB(t testing.TB, conn *pgx.Conn, msg string) {
|
||||
if conn.PgConn().ParameterStatus("crdb_version") != "" {
|
||||
t.Skip(msg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/jackc/pgx/v5/pgxtest"
|
||||
)
|
||||
|
||||
func TestLargeObjects(t *testing.T) {
|
||||
@@ -22,7 +23,7 @@ func TestLargeObjects(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
skipCockroachDB(t, conn, "Server does support large objects")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does support large objects")
|
||||
|
||||
tx, err := conn.Begin(ctx)
|
||||
if err != nil {
|
||||
@@ -50,7 +51,7 @@ func TestLargeObjectsSimpleProtocol(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
skipCockroachDB(t, conn, "Server does support large objects")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does support large objects")
|
||||
|
||||
tx, err := conn.Begin(ctx)
|
||||
if err != nil {
|
||||
@@ -169,7 +170,7 @@ func TestLargeObjectsMultipleTransactions(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
skipCockroachDB(t, conn, "Server does support large objects")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does support large objects")
|
||||
|
||||
tx, err := conn.Begin(ctx)
|
||||
if err != nil {
|
||||
|
||||
@@ -86,3 +86,10 @@ func RunWithQueryExecModes(ctx context.Context, t *testing.T, ctr ConnTestRunner
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// SkipCockroachDB calls Skip on t with msg if the connection is to a CockroachDB server.
|
||||
func SkipCockroachDB(t testing.TB, conn *pgx.Conn, msg string) {
|
||||
if conn.PgConn().ParameterStatus("crdb_version") != "" {
|
||||
t.Skip(msg)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -269,7 +269,7 @@ func TestRowsScanDoesNotAllowScanningBinaryFormatValuesIntoString(t *testing.T)
|
||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer closeConn(t, conn)
|
||||
|
||||
skipCockroachDB(t, conn, "Server does not support point type")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does not support point type")
|
||||
|
||||
var s string
|
||||
|
||||
@@ -477,7 +477,7 @@ func TestConnQueryDeferredError(t *testing.T) {
|
||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer closeConn(t, conn)
|
||||
|
||||
skipCockroachDB(t, conn, "Server does not support deferred constraint (https://github.com/cockroachdb/cockroach/issues/31632)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does not support deferred constraint (https://github.com/cockroachdb/cockroach/issues/31632)")
|
||||
|
||||
mustExec(t, conn, `create temporary table t (
|
||||
id text primary key,
|
||||
@@ -519,7 +519,7 @@ func TestConnQueryErrorWhileReturningRows(t *testing.T) {
|
||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer closeConn(t, conn)
|
||||
|
||||
skipCockroachDB(t, conn, "Server uses numeric instead of int")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server uses numeric instead of int")
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
func() {
|
||||
@@ -1267,7 +1267,7 @@ func TestQueryContextErrorWhileReceivingRows(t *testing.T) {
|
||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer closeConn(t, conn)
|
||||
|
||||
skipCockroachDB(t, conn, "Server uses numeric instead of int")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server uses numeric instead of int")
|
||||
|
||||
ctx, cancelFunc := context.WithCancel(context.Background())
|
||||
defer cancelFunc()
|
||||
@@ -1789,7 +1789,7 @@ func TestConnSimpleProtocolRefusesNonUTF8ClientEncoding(t *testing.T) {
|
||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer closeConn(t, conn)
|
||||
|
||||
skipCockroachDB(t, conn, "Server does not support changing client_encoding (https://www.cockroachlabs.com/docs/stable/set-vars.html)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does not support changing client_encoding (https://www.cockroachlabs.com/docs/stable/set-vars.html)")
|
||||
|
||||
mustExec(t, conn, "set client_encoding to 'SQL_ASCII'")
|
||||
|
||||
@@ -1813,7 +1813,7 @@ func TestConnSimpleProtocolRefusesNonStandardConformingStrings(t *testing.T) {
|
||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer closeConn(t, conn)
|
||||
|
||||
skipCockroachDB(t, conn, "Server does not support standard_conforming_strings = off (https://github.com/cockroachdb/cockroach/issues/36215)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does not support standard_conforming_strings = off (https://github.com/cockroachdb/cockroach/issues/36215)")
|
||||
|
||||
mustExec(t, conn, "set standard_conforming_strings to off")
|
||||
|
||||
|
||||
+3
-2
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/jackc/pgx/v5/pgxtest"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -106,7 +107,7 @@ func TestTxCommitWhenDeferredConstraintFailure(t *testing.T) {
|
||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer closeConn(t, conn)
|
||||
|
||||
skipCockroachDB(t, conn, "Server does not support deferred constraint (https://github.com/cockroachdb/cockroach/issues/31632)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server does not support deferred constraint (https://github.com/cockroachdb/cockroach/issues/31632)")
|
||||
|
||||
createSql := `
|
||||
create temporary table foo(
|
||||
@@ -273,7 +274,7 @@ func TestBeginIsoLevels(t *testing.T) {
|
||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||
defer closeConn(t, conn)
|
||||
|
||||
skipCockroachDB(t, conn, "Server always uses SERIALIZABLE isolation (https://www.cockroachlabs.com/docs/stable/demo-serializable.html)")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server always uses SERIALIZABLE isolation (https://www.cockroachlabs.com/docs/stable/demo-serializable.html)")
|
||||
|
||||
isoLevels := []pgx.TxIsoLevel{pgx.Serializable, pgx.RepeatableRead, pgx.ReadCommitted, pgx.ReadUncommitted}
|
||||
for _, iso := range isoLevels {
|
||||
|
||||
+1
-1
@@ -718,7 +718,7 @@ func TestPointerPointer(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||
skipCockroachDB(t, conn, "Server auto converts ints to bigint and test relies on exact types")
|
||||
pgxtest.SkipCockroachDB(t, conn, "Server auto converts ints to bigint and test relies on exact types")
|
||||
|
||||
type allTypes struct {
|
||||
s *string
|
||||
|
||||
Reference in New Issue
Block a user