Skip to content

Commit 4722ba2

Browse files
committed
Make sure we set up the running dbs
1 parent b827439 commit 4722ba2

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Tests/AppTests/Helpers/DatabasePool.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,25 @@ actor DatabasePool {
4040
var availableDatabases: Set<Database> = .init()
4141

4242
func setUp() async throws {
43-
print("ℹ️ DatabasePool size:", Environment.databasePoolSize)
44-
4543
// Call DotEnvFile.load once to ensure env variables are set
4644
await DotEnvFile.load(for: .testing, fileio: .init(threadPool: .singleton))
4745

4846
if isRunningInCI() {
4947
// We don't have docker available in CI to probe for running dbs.
5048
// Instead, we have a hard-coded list of dbs we launch in the GH workflow
5149
// file and correspondingly, we hard-code their ports here.
52-
availableDatabases = Set((6000..<6008).map(Database.init))
50+
let runningDbs = Set((6000..<6008).map(Database.init))
51+
try await withThrowingTaskGroup(of: Database.self) { group in
52+
for db in runningDbs {
53+
group.addTask {
54+
try await db.setup(for: .testing)
55+
return db
56+
}
57+
}
58+
for try await db in group {
59+
availableDatabases.insert(db)
60+
}
61+
}
5362
} else {
5463
// Re-use up to maxCount running dbs
5564
let runningDbs = try await runningDatabases()
@@ -78,11 +87,11 @@ actor DatabasePool {
7887
}
7988
}
8089
}
90+
91+
print("ℹ️ availableDatabases:", availableDatabases.count)
8192
}
8293

8394
func tearDown() async throws {
84-
print("ℹ️ DatabasePool size:", Environment.databasePoolSize)
85-
8695
if isRunningInCI() {
8796
// Let CI's tear down deal with the databases, there's nothing we can or should do here.
8897
} else {

0 commit comments

Comments
 (0)