Skip to content

Commit

Permalink
Fix linting error
Browse files Browse the repository at this point in the history
  • Loading branch information
owenthereal committed Dec 4, 2023
1 parent cf2917f commit b22bb48
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
9 changes: 4 additions & 5 deletions acceptance/shared/cases.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import (
)

const (
PGVersionUnknown PGVersion = "unknown"
PGVersion13 PGVersion = "13"
PGVersion14 PGVersion = "14"
PGVersion15 PGVersion = "15"
PGVersion16 PGVersion = "16"
PGVersion13 PGVersion = "13"
PGVersion14 PGVersion = "14"
PGVersion15 PGVersion = "15"
PGVersion16 PGVersion = "16"
)

type PGVersion string
Expand Down
10 changes: 5 additions & 5 deletions acceptance/shared/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package shared

import (
"context"
"fmt"
"regexp"
"testing"

"github.com/jackc/pgx/v5/pgxpool"
)
Expand All @@ -12,18 +12,18 @@ var (
regexpPGVersion = regexp.MustCompile(`^PostgreSQL (\d+)`)
)

func QueryPGVersion(ctx context.Context, pool *pgxpool.Pool) (PGVersion, error) {
func QueryPGVersion(t *testing.T, ctx context.Context, pool *pgxpool.Pool) PGVersion {
row := pool.QueryRow(ctx, "SELECT VERSION();")

var version string
if err := row.Scan(&version); err != nil {
return PGVersionUnknown, err
t.Fatal(err)
}

matches := regexpPGVersion.FindStringSubmatch(version)
if len(matches) == 0 {
return PGVersionUnknown, fmt.Errorf("failed to parse pg_config --version output: %s", version)
t.Fatalf("failed to parse pg_config --version output: %s", version)
}

return PGVersion(matches[1]), nil
return PGVersion(matches[1])
}
15 changes: 3 additions & 12 deletions acceptance/shared/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ func RunAcceptanceTests(t *testing.T, ctx context.Context, cm DockerComposeManag
})

pool := cm.PGPool()
ver, err := QueryPGVersion(ctx, pool)
if err != nil {
t.Fatal(err)
}
ver := QueryPGVersion(t, ctx, pool)

cases := append(AcceptanceCases(), additionalCases...)
for _, c := range cases {
Expand Down Expand Up @@ -76,10 +73,7 @@ func RunUpgradeTests(t *testing.T, ctx context.Context, cm DockerComposeManager)
c := c

pool := cm.PGPool()
ver, err := QueryPGVersion(ctx, pool)
if err != nil {
t.Fatal(err)
}
ver := QueryPGVersion(t, ctx, pool)

t.Run(c.Name, func(t *testing.T) {
checkSkipTest(t, c, ver)
Expand Down Expand Up @@ -107,10 +101,7 @@ func RunUpgradeTests(t *testing.T, ctx context.Context, cm DockerComposeManager)
c := c

pool := cm.PGPool()
ver, err := QueryPGVersion(ctx, pool)
if err != nil {
t.Fatal(err)
}
ver := QueryPGVersion(t, ctx, pool)

t.Run(c.Name, func(t *testing.T) {
checkSkipTest(t, c, ver)
Expand Down

0 comments on commit b22bb48

Please sign in to comment.