feat: Adds project database tests.
All checks were successful
CI / Linux Tests (push) Successful in 5m24s

This commit is contained in:
2026-01-30 14:02:58 -05:00
parent c32ffcff8c
commit a51e1b34d0
7 changed files with 297 additions and 73 deletions

View File

@@ -4,10 +4,11 @@ import Dependencies
import Fluent
import FluentSQLiteDriver
import Foundation
import ManualDCore
import NIO
import Vapor
// Helper to create an in-memory database for testing.
// Helper to create an in-memory database used for testing.
func withDatabase(
setupDependencies: (inout DependencyValues) -> Void = { _ in },
operation: () async throws -> Void
@@ -37,3 +38,18 @@ func withDatabase(
}
}
/// Set's up the database and a test user for running tests that require a
/// a user.
func withTestUser(
setupDependencies: (inout DependencyValues) -> Void = { _ in },
operation: (User) async throws -> Void
) async throws {
try await withDatabase(setupDependencies: setupDependencies) {
@Dependency(\.database.users) var users
let user = try await users.create(
.init(email: "testy@example.com", password: "super-secret", confirmPassword: "super-secret")
)
try await operation(user)
}
}