test(17-06): read -short through testing.Short in the Postgres harnesses

go test passes -test.short=true, so scanning os.Args for -test.short
never matched and every -short run started a Postgres container. The
three TestMains now parse the flags and ask testing.Short.
This commit is contained in:
2026-10-12 19:31:45 +02:00
parent 06d0c9bc2c
commit 4e2aab6fe0
3 changed files with 15 additions and 18 deletions

View File

@@ -5,6 +5,7 @@ import (
"context"
"database/sql"
"encoding/json"
"flag"
"fmt"
"io"
"net/http"
@@ -67,13 +68,11 @@ func TestMain(m *testing.M) {
os.Exit(code)
}
// testShort reports -short. go test passes -test.short=true, so the flags
// are parsed and read through testing.Short, never by scanning os.Args.
func testShort() bool {
for _, a := range os.Args {
if a == "-test.short" {
return true
}
}
return false
flag.Parse()
return testing.Short()
}
func startAdminPostgres(ctx context.Context) error {

View File

@@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"encoding/json"
"flag"
"fmt"
"os"
"testing"
@@ -45,13 +46,11 @@ func TestMain(m *testing.M) {
os.Exit(code)
}
// testShort reports -short. go test passes -test.short=true, so the flags
// are parsed and read through testing.Short, never by scanning os.Args.
func testShort() bool {
for _, a := range os.Args {
if a == "-test.short" {
return true
}
}
return false
flag.Parse()
return testing.Short()
}
func startJournalPostgres(ctx context.Context) error {

View File

@@ -3,6 +3,7 @@ package updates
import (
"context"
"database/sql"
"flag"
"fmt"
"net/url"
"os"
@@ -43,13 +44,11 @@ func TestMain(m *testing.M) {
os.Exit(code)
}
// testShort reports -short. go test passes -test.short=true, so the flags
// are parsed and read through testing.Short, never by scanning os.Args.
func testShort() bool {
for _, a := range os.Args {
if a == "-test.short" {
return true
}
}
return false
flag.Parse()
return testing.Short()
}
func startJournalPostgres(ctx context.Context) error {