Remove github.com/shopspring/decimal test dependency

query-exec-mode
Jack Christensen 2021-12-11 14:32:32 -06:00
parent 9ab821620f
commit 731312fea8
3 changed files with 9 additions and 31 deletions

1
go.mod
View File

@ -13,7 +13,6 @@ require (
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b
github.com/jackc/puddle v1.2.0
github.com/rs/zerolog v1.15.0
github.com/shopspring/decimal v1.2.0
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.7.0
go.uber.org/zap v1.13.0

2
go.sum
View File

@ -88,8 +88,6 @@ github.com/rs/zerolog v1.15.0 h1:uPRuwkWF4J6fGsJ2R0Gn2jB1EQiav9k3S6CSdygQJXY=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=

View File

@ -18,7 +18,6 @@ import (
"github.com/jackc/pgx/v5/pgconn"
"github.com/jackc/pgx/v5/pgconn/stmtcache"
"github.com/jackc/pgx/v5/pgtype"
"github.com/shopspring/decimal"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@ -1154,55 +1153,37 @@ func TestReadingNullByteArrays(t *testing.T) {
}
}
// Use github.com/shopspring/decimal as real-world database/sql custom type
// to test against.
func TestConnQueryDatabaseSQLScanner(t *testing.T) {
t.Parallel()
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
defer closeConn(t, conn)
var num decimal.Decimal
var num sql.NullFloat64
err := conn.QueryRow(context.Background(), "select '1234.567'::decimal").Scan(&num)
err := conn.QueryRow(context.Background(), "select '1234.567'::float8").Scan(&num)
if err != nil {
t.Fatalf("Scan failed: %v", err)
}
expected, err := decimal.NewFromString("1234.567")
if err != nil {
t.Fatal(err)
}
if !num.Equals(expected) {
t.Errorf("Expected num to be %v, but it was %v", expected, num)
}
require.True(t, num.Valid)
require.Equal(t, 1234.567, num.Float64)
ensureConnValid(t, conn)
}
// Use github.com/shopspring/decimal as real-world database/sql custom type
// to test against.
func TestConnQueryDatabaseSQLDriverValuer(t *testing.T) {
t.Parallel()
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
defer closeConn(t, conn)
expected, err := decimal.NewFromString("1234.567")
if err != nil {
t.Fatal(err)
}
var num decimal.Decimal
expected := sql.NullFloat64{Float64: 1234.567, Valid: true}
var actual sql.NullFloat64
err = conn.QueryRow(context.Background(), "select $1::decimal", &expected).Scan(&num)
if err != nil {
t.Fatalf("Scan failed: %v", err)
}
if !num.Equals(expected) {
t.Errorf("Expected num to be %v, but it was %v", expected, num)
}
err := conn.QueryRow(context.Background(), "select $1::float8", &expected).Scan(&actual)
require.NoError(t, err)
require.Equal(t, expected, actual)
ensureConnValid(t, conn)
}