Skip to content

Commit 3ebf94d

Browse files
committed
Enable CI to specify environment more sparsely
1 parent 22e581c commit 3ebf94d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,11 @@ extension DatabaseConfigurationFactory {
322322
decodingContext: PostgresDecodingContext<some PostgresJSONDecoder> = .default
323323
) -> Self {
324324
let baseSubconfig = SQLPostgresConfiguration(
325-
hostname: ProcessInfo.processInfo.environment["POSTGRES_HOSTNAME_\(subconfig)"] ?? "localhost",
326-
port: ProcessInfo.processInfo.environment["POSTGRES_PORT_\(subconfig)"].flatMap(Int.init) ?? SQLPostgresConfiguration.ianaPortNumber,
327-
username: ProcessInfo.processInfo.environment["POSTGRES_USER_\(subconfig)"] ?? "test_username",
328-
password: ProcessInfo.processInfo.environment["POSTGRES_PASSWORD_\(subconfig)"] ?? "test_password",
329-
database: ProcessInfo.processInfo.environment["POSTGRES_DB_\(subconfig)"] ?? "test_database",
325+
hostname: env("POSTGRES_HOSTNAME_\(subconfig)") ?? env("POSTGRES_HOSTNAME_A") ?? env("POSTGRES_HOSTNAME") ?? "localhost",
326+
port: (env("POSTGRES_PORT_\(subconfig)") ?? env("POSTGRES_PORT_A") ?? env("POSTGRES_PORT")).flatMap(Int.init) ?? SQLPostgresConfiguration.ianaPortNumber,
327+
username: env("POSTGRES_USER_\(subconfig)") ?? env("POSTGRES_USER_A") ?? env("POSTGRES_USER") ?? "test_username",
328+
password: env("POSTGRES_PASSWORD_\(subconfig)") ?? env("POSTGRES_PASSWORD_A") ?? env("POSTGRES_PASSWORD") ?? "test_password",
329+
database: env("POSTGRES_DB_\(subconfig)") ?? env("POSTGRES_DB_A") ?? env("POSTGRES_DB") ?? "test_database",
330330
tls: try! .prefer(.init(configuration: .makeClientConfiguration()))
331331
)
332332

@@ -445,8 +445,12 @@ struct EnumAddMultipleCasesMigration: AsyncMigration {
445445
}
446446
}
447447

448+
func env(_ e: String) -> String? {
449+
ProcessInfo.processInfo.environment[e]
450+
}
451+
448452
let isLoggingConfigured: Bool = {
449-
LoggingSystem.bootstrap { QuickLogHandler(label: $0, level: ProcessInfo.processInfo.environment["LOG_LEVEL"].flatMap { .init(rawValue: $0) } ?? .info) }
453+
LoggingSystem.bootstrap { QuickLogHandler(label: $0, level: env("LOG_LEVEL").flatMap { .init(rawValue: $0) } ?? .info) }
450454
return true
451455
}()
452456

0 commit comments

Comments
 (0)