test: honour -short in Docker-backed TestMain and cabana list-service fixture
TestMain scanned os.Args for a literal -test.short, but go test passes -test.short=true, so beachcomber, conga, lagoon and lighthouse started a Postgres container even under -short. Parse the flags and use testing.Short() instead; skip cabana's newListService fixture under -short like adminGorm already does.
This commit is contained in:
@@ -3,6 +3,7 @@ package lighthouse
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -42,13 +43,14 @@ func TestMain(m *testing.M) {
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
// testShort reports whether -short was passed. TestMain runs before the
|
||||
// testing flags are parsed, and go test passes the flag as -test.short=true,
|
||||
// so parse the flags here instead of scanning os.Args.
|
||||
func testShort() bool {
|
||||
for _, a := range os.Args {
|
||||
if a == "-test.short" {
|
||||
return true
|
||||
}
|
||||
if !flag.Parsed() {
|
||||
flag.Parse()
|
||||
}
|
||||
return false
|
||||
return testing.Short()
|
||||
}
|
||||
|
||||
func startLighthousePostgres(ctx context.Context) error {
|
||||
|
||||
Reference in New Issue
Block a user