@@ -50,11 +50,7 @@ extension AppTestCase {
50
50
51
51
static func setupApp( _ environment: Environment ) async throws -> Application {
52
52
let app = try await Application . make ( environment)
53
- let host = try await configure ( app)
54
-
55
- // Ensure `.testing` refers to certain restricted db hostnames and nothing else
56
- precondition ( [ " localhost " , " postgres " , " host.docker.internal " ] . contains ( host) ,
57
- " .testing must be a local db, was: \( host) " )
53
+ try await configure ( app)
58
54
59
55
// Silence app logging
60
56
app. logger = . init( label: " noop " ) { _ in SwiftLogNoOpLogHandler ( ) }
@@ -65,6 +61,14 @@ extension AppTestCase {
65
61
66
62
static func setupDb( _ environment: Environment ) async throws {
67
63
await DotEnvFile . load ( for: environment, fileio: . init( threadPool: . singleton) )
64
+
65
+ // Ensure DATABASE_HOST is from a restricted set db hostnames and nothing else.
66
+ // This is safeguard against accidental inheritance of setup in QueryPerformanceTests
67
+ // and to ensure the database resetting cannot impact any other network hosts.
68
+ let host = Environment . get ( " DATABASE_HOST " )
69
+ precondition ( [ " localhost " , " postgres " , " host.docker.internal " ] . contains ( host) ,
70
+ " DATABASE_HOST must be a local db, was: \( host) " )
71
+
68
72
let testDbName = Environment . get ( " DATABASE_NAME " ) !
69
73
let snapshotName = testDbName + " _snapshot "
70
74
0 commit comments