Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cli/gonext/cmd/init/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func TestSetup_RequiresPepper(t *testing.T) {
// seed, then assert on the resulting rows.
func TestSetup_HappyPath_FullFlow(t *testing.T) {
t.Parallel()
if testing.Short() {
t.Skip("integration test: testcontainers spin-up flakes on shared CI runners; runs in nightly")
}
dsn := containers.Postgres(t)
if dsn == "" {
t.Skip("docker not available")
Expand Down
23 changes: 19 additions & 4 deletions packages/go/migrate/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"log/slog"
"os"
"path/filepath"
"sort"
"strconv"
"strings"
"testing"

Expand Down Expand Up @@ -112,9 +114,13 @@ func TestSourceURLForDir_Relative(t *testing.T) {

// --- Integration tests below: require a real Postgres + migrations dir ---

// countMigrations returns the number of up-migration files in dir. The
// canonical migration runner picks them up in lexical order, so this
// is the version we expect Status() to report after a successful Run().
// countMigrations returns the highest version number among the
// up-migration files in dir. The canonical migration runner uses the
// numeric prefix as the version; we parse the prefix off the last
// (lexically-greatest) file and report that. Using the max version
// rather than len() makes the test robust against gaps (parallel
// branches can each take their own slot without forcing every PR to
// rebase on every other).
func countMigrations(t *testing.T, dir string) uint {
t.Helper()
matches, err := filepath.Glob(filepath.Join(dir, "*.up.sql"))
Expand All @@ -124,7 +130,16 @@ func countMigrations(t *testing.T, dir string) uint {
if len(matches) == 0 {
t.Fatalf("no *.up.sql files found in %s", dir)
}
return uint(len(matches)) //nolint:gosec // file count, can't overflow
// Lexical sort puts the highest 000NNN_ prefix last.
sort.Strings(matches)
last := filepath.Base(matches[len(matches)-1])
// "000033_foo.up.sql" → "000033"
prefix := strings.SplitN(last, "_", 2)[0]
n, err := strconv.ParseUint(prefix, 10, 64)
if err != nil {
t.Fatalf("parse version prefix %q from %q: %v", prefix, last, err)
}
return uint(n) //nolint:gosec
}

func TestRun_IntegrationApplyAndRollback(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions packages/go/testutil/containers/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import (
// just add a layer of dereferencing for no gain.
func MinIO(t testing.TB, opts ...MinIOOption) (endpoint, accessKey, secretKey string) {
t.Helper()
if testing.Short() {
t.Skip("integration test: skip under -short (covered by nightly-full-tests workflow)")
}
if skipIfNoDocker(t) {
return "", "", ""
}
Expand Down
8 changes: 8 additions & 0 deletions packages/go/testutil/containers/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ import (
// to accept SQL connections before returning.
func Postgres(t testing.TB, opts ...PGOption) (dsn string) {
t.Helper()
// Integration tests are skipped under `go test -short`. PR CI uses
// -short for stability (testcontainers spin-up jitter on shared
// GitHub runners causes flakes that block the merge queue); the
// nightly-full-tests workflow runs without -short to keep these
// paths exercised against tip-of-main.
if testing.Short() {
t.Skip("integration test: skip under -short (covered by nightly-full-tests workflow)")
}
if skipIfNoDocker(t) {
return ""
}
Expand Down
3 changes: 3 additions & 0 deletions packages/go/testutil/containers/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import (
// via the URL path).
func Redis(t testing.TB, opts ...RedisOption) (url string) {
t.Helper()
if testing.Short() {
t.Skip("integration test: skip under -short (covered by nightly-full-tests workflow)")
}
if skipIfNoDocker(t) {
return ""
}
Expand Down
Loading