2
0

Skipped multirange tests for postgres less than 14 version

This commit is contained in:
Vitalii Solodilov
2022-11-29 12:34:26 +07:00
committed by Jack Christensen
parent 8e2de2fefa
commit 88b373f9ee
2 changed files with 52 additions and 14 deletions
+20
View File
@@ -5,6 +5,8 @@ import (
"context"
"fmt"
"reflect"
"regexp"
"strconv"
"testing"
"github.com/jackc/pgx/v5"
@@ -151,3 +153,21 @@ func SkipCockroachDB(t testing.TB, conn *pgx.Conn, msg string) {
t.Skip(msg)
}
}
func SkipPostgreSQLVersionLessThan(t testing.TB, conn *pgx.Conn, minVersion int64) {
serverVersionStr := conn.PgConn().ParameterStatus("server_version")
serverVersionStr = regexp.MustCompile(`^[0-9]+`).FindString(serverVersionStr)
// if not PostgreSQL do nothing
if serverVersionStr == "" {
return
}
serverVersion, err := strconv.ParseInt(serverVersionStr, 10, 64)
if err != nil {
t.Fatalf("postgres version parsed failed: %s", err)
}
if serverVersion < minVersion {
t.Skipf("Test requires PostgreSQL v%d+", minVersion)
}
}