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:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user