Skip to content

Commit b32d42b

Browse files
committed
Make databasePort optional
1 parent 79a3fa3 commit b32d42b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Tests/AppTests/AppTestCase.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import XCTVapor
2626
#warning("move/rename")
2727
enum AppTestCase {
2828

29-
static func setupApp(_ environment: Environment, databasePort: Int) async throws -> Application {
29+
static func setupApp(_ environment: Environment, databasePort: Int? = nil) async throws -> Application {
3030
let app = try await Application.make(environment)
3131
try await configure(app, databasePort: databasePort)
3232

@@ -37,13 +37,14 @@ enum AppTestCase {
3737
}
3838

3939

40-
static func setupDb(_ environment: Environment, databasePort: Int) async throws {
40+
static func setupDb(_ environment: Environment, databasePort: Int? = nil) async throws {
4141
await DotEnvFile.load(for: environment, fileio: .init(threadPool: .singleton))
4242

4343
// Ensure DATABASE_HOST is from a restricted set db hostnames and nothing else.
4444
// This is safeguard against accidental inheritance of setup in QueryPerformanceTests
4545
// and to ensure the database resetting cannot impact any other network hosts.
4646
let host = Environment.get("DATABASE_HOST")
47+
let databasePort = databasePort ?? Environment.get("DATABASE_PORT").flatMap(Int.init)!
4748
precondition(["localhost", "postgres", "host.docker.internal"].contains(host),
4849
"DATABASE_HOST must be a local db, was: \(host)")
4950

@@ -166,7 +167,6 @@ private func connect(to databaseName: String,
166167
_ environment: Environment) async throws -> PostgresClient {
167168
await DotEnvFile.load(for: environment, fileio: .init(threadPool: .singleton))
168169
let host = Environment.get("DATABASE_HOST")!
169-
// let port = Environment.get("DATABASE_PORT").flatMap(Int.init)!
170170
let username = Environment.get("DATABASE_USERNAME")!
171171
let password = Environment.get("DATABASE_PASSWORD")!
172172

0 commit comments

Comments
 (0)