2
0

pgtype uses pgxtest

Added ValueRoundTripTest to pgxtest
Removed pgtype/testutil

pgtype tests now run with all (applicable) query modes. This gives
better coverage than before and revealed several bugs which are also
fixed in this commit.
This commit is contained in:
Jack Christensen
2022-04-02 14:34:19 -05:00
parent 83e50f21e8
commit ee93440ac1
54 changed files with 2028 additions and 1954 deletions
+19 -17
View File
@@ -4,30 +4,32 @@ import (
"context"
"testing"
pgx "github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgtype"
"github.com/jackc/pgx/v5/pgtype/testutil"
"github.com/jackc/pgx/v5/pgxtest"
)
func TestLineTranscode(t *testing.T) {
skipCockroachDB(t, "Server does not support type line")
ctr := defaultConnTestRunner
ctr.AfterConnect = func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
pgxtest.SkipCockroachDB(t, conn, "Server does not support type line")
conn := testutil.MustConnectPgx(t)
defer conn.Close(context.Background())
if _, ok := conn.TypeMap().TypeForName("line"); !ok {
t.Skip("Skipping due to no line type")
if _, ok := conn.TypeMap().TypeForName("line"); !ok {
t.Skip("Skipping due to no line type")
}
// line may exist but not be usable on 9.3 :(
var isPG93 bool
err := conn.QueryRow(context.Background(), "select version() ~ '9.3'").Scan(&isPG93)
if err != nil {
t.Fatal(err)
}
if isPG93 {
t.Skip("Skipping due to unimplemented line type in PG 9.3")
}
}
// line may exist but not be usable on 9.3 :(
var isPG93 bool
err := conn.QueryRow(context.Background(), "select version() ~ '9.3'").Scan(&isPG93)
if err != nil {
t.Fatal(err)
}
if isPG93 {
t.Skip("Skipping due to unimplemented line type in PG 9.3")
}
testutil.RunTranscodeTests(t, "line", []testutil.TranscodeTestCase{
pgxtest.RunValueRoundTripTests(context.Background(), t, ctr, nil, "line", []pgxtest.ValueRoundTripTest{
{
pgtype.Line{
A: 1.23, B: 4.56, C: 7.89012345,