//go:build integration package inventory import ( "context" "os" "strings" "testing" "time" "github.com/jackc/pgx/v5/pgconn" ) func TestAWrongPasswordIsAnAnswerNotAnOutage(t *testing.T) { dsn := os.Getenv("MESH_TEST_POSTGRES") if dsn == "" { t.Skip("MESH_TEST_POSTGRES is not set") } wrong := strings.Replace(dsn, "postgres:check@", "postgres:not-the-password@", 1) if wrong == dsn { t.Skip("the test store's address does not carry the expected credential") } ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() _, err := pgconn.Connect(ctx, wrong) if err == nil { t.Fatal("a wrong password connected") } if Unreachable(err) { t.Fatalf("a wrong password was taken for an outage and would be retried for ever: %v", err) } }