Remove github.com/Masterminds/semver/v3 test dependency

query-exec-mode
Jack Christensen 2021-12-11 14:27:00 -06:00
parent 1b416b36dc
commit 9ab821620f
3 changed files with 7 additions and 14 deletions

1
go.mod
View File

@ -3,7 +3,6 @@ module github.com/jackc/pgx/v5
go 1.17
require (
github.com/Masterminds/semver/v3 v3.1.1
github.com/go-kit/log v0.1.0
github.com/gofrs/uuid v4.0.0+incompatible
github.com/jackc/chunkreader/v2 v2.0.1

2
go.sum
View File

@ -1,7 +1,5 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=

View File

@ -9,10 +9,10 @@ import (
"os"
"reflect"
"regexp"
"strconv"
"testing"
"time"
"github.com/Masterminds/semver/v3"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"
"github.com/jackc/pgx/v5/stdlib"
@ -46,7 +46,7 @@ func skipCockroachDB(t testing.TB, db *sql.DB, msg string) {
require.NoError(t, err)
}
func skipPostgreSQLVersion(t testing.TB, db *sql.DB, constraintStr, msg string) {
func skipPostgreSQLVersionLessThan(t testing.TB, db *sql.DB, minVersion int64) {
conn, err := db.Conn(context.Background())
require.NoError(t, err)
defer conn.Close()
@ -54,25 +54,21 @@ func skipPostgreSQLVersion(t testing.TB, db *sql.DB, constraintStr, msg string)
err = conn.Raw(func(driverConn interface{}) error {
conn := driverConn.(*stdlib.Conn).Conn()
serverVersionStr := conn.PgConn().ParameterStatus("server_version")
serverVersionStr = regexp.MustCompile(`^[0-9.]+`).FindString(serverVersionStr)
serverVersionStr = regexp.MustCompile(`^[0-9]+`).FindString(serverVersionStr)
// if not PostgreSQL do nothing
if serverVersionStr == "" {
return nil
}
serverVersion, err := semver.NewVersion(serverVersionStr)
serverVersion, err := strconv.ParseInt(serverVersionStr, 10, 64)
if err != nil {
return err
}
c, err := semver.NewConstraint(constraintStr)
if err != nil {
return err
if serverVersion < minVersion {
t.Skipf("Test requires PostgreSQL v%d+", minVersion)
}
if c.Check(serverVersion) {
t.Skip(msg)
}
return nil
})
require.NoError(t, err)
@ -1093,7 +1089,7 @@ func TestRegisterConnConfig(t *testing.T) {
// https://github.com/jackc/pgx/issues/958
func TestConnQueryRowConstraintErrors(t *testing.T) {
testWithAndWithoutPreferSimpleProtocol(t, func(t *testing.T, db *sql.DB) {
skipPostgreSQLVersion(t, db, "< 11", "Test requires PG 11+")
skipPostgreSQLVersionLessThan(t, db, 11)
skipCockroachDB(t, db, "Server does not support deferred constraint (https://github.com/cockroachdb/cockroach/issues/31632)")
_, err := db.Exec(`create temporary table defer_test (