Skip to content

Commit c88b423

Browse files
Disable sync migrations
1 parent a6fc40c commit c88b423

File tree

2 files changed

+7
-51
lines changed

2 files changed

+7
-51
lines changed

Sources/AlchemyTest/Fakes/Database+Fake.swift

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,15 @@ extension Database {
88
/// - seeders: Any seeders to set on the database, they will be run before
99
/// this function returns.
1010
@discardableResult
11-
public static func fake(_ id: Identifier = .default, migrations: [Migration] = [], seeders: [Seeder] = []) -> Database {
11+
public static func fake(_ id: Identifier = .default, migrations: [Migration] = [], seeders: [Seeder] = []) async throws -> Database {
1212
let db = Database.sqlite
1313
db.migrations = migrations
1414
db.seeders = seeders
1515
bind(id, db)
1616

17-
let sem = DispatchSemaphore(value: 0)
18-
Task {
19-
do {
20-
if !migrations.isEmpty { try await db.migrate() }
21-
if !seeders.isEmpty { try await db.seed() }
22-
} catch {
23-
Log.error("Error initializing fake database: \(error)")
24-
}
25-
26-
sem.signal()
27-
}
17+
if !migrations.isEmpty { try await db.migrate() }
18+
if !seeders.isEmpty { try await db.seed() }
2819

29-
sem.wait()
3020
return db
3121
}
32-
33-
/// Synchronously migrates the database, useful for setting up the database
34-
/// before test cases.
35-
public func syncMigrate() {
36-
let sem = DispatchSemaphore(value: 0)
37-
Task {
38-
do {
39-
if !migrations.isEmpty { try await migrate() }
40-
} catch {
41-
Log.error("Error migrating test database: \(error)")
42-
}
43-
44-
sem.signal()
45-
}
46-
47-
sem.wait()
48-
}
49-
50-
/// Synchronously seeds the database, useful for setting up the database
51-
/// before test cases.
52-
public func syncSeed() {
53-
let sem = DispatchSemaphore(value: 0)
54-
Task {
55-
do {
56-
if !seeders.isEmpty { try await seed() }
57-
} catch {
58-
Log.error("Error seeding test database: \(error)")
59-
}
60-
61-
sem.signal()
62-
}
63-
64-
sem.wait()
65-
}
6622
}

Sources/AlchemyTest/TestCase/TestCase.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ open class TestCase<A: Application>: XCTestCase {
4343
public var app = A()
4444
public var Test: Builder { Builder() }
4545

46-
open override func setUpWithError() throws {
47-
try super.setUpWithError()
46+
open override func setUp() async throws {
47+
try await super.setUp()
4848
app = A()
4949
try app.setup()
5050
}
5151

52-
open override func tearDownWithError() throws {
53-
try super.tearDownWithError()
52+
open override func tearDown() async throws {
53+
try await super.tearDown()
5454
try app.stop()
5555
}
5656
}

0 commit comments

Comments
 (0)