feat: Adds script to generate database seeded values and removes old mock storage.

This commit is contained in:
2025-01-16 21:00:27 -05:00
parent 09b46f672a
commit e1d07008a1
16 changed files with 399 additions and 535 deletions

View File

@@ -49,12 +49,10 @@ struct DatabaseClientTests {
}
}
@Test(arguments: EmployeeTestFactory.testCases)
func employees(factory: EmployeeTestFactory) async throws {
@Test
func employees() async throws {
try await withDatabase(migrations: Employee.Migrate()) {
$0.uuid = .incrementing
$0.date = .init { Date() }
$0.database.employees = factory.handler($1)
$0.database.employees = .live(database: $1)
} operation: {
@Dependency(\.database.employees) var employees
@@ -93,11 +91,11 @@ struct DatabaseClientTests {
}
}
@Test(arguments: VendorTestFactory.testCases)
func vendors(factory: VendorTestFactory) async throws {
@Test
func vendors() async throws {
try await withDatabase(migrations: Vendor.Migrate(), VendorBranch.Migrate()) {
$0.database.vendorBranches = factory.handler($1).0
$0.database.vendors = factory.handler($1).1
$0.database.vendorBranches = .live(database: $1)
$0.database.vendors = .live(database: $1)
} operation: {
@Dependency(\.database.vendorBranches) var branches
@Dependency(\.database.vendors) var vendors
@@ -132,11 +130,11 @@ struct DatabaseClientTests {
}
}
@Test(arguments: VendorTestFactory.testCases)
func vendorBranches(factory: VendorTestFactory) async throws {
@Test
func vendorBranches() async throws {
try await withDatabase(migrations: Vendor.Migrate(), VendorBranch.Migrate()) {
$0.database.vendorBranches = factory.handler($1).0
$0.database.vendors = factory.handler($1).1
$0.database.vendorBranches = .live(database: $1)
$0.database.vendors = .live(database: $1)
} operation: {
@Dependency(\.database.vendorBranches) var branches
@Dependency(\.database.vendors) var vendors
@@ -197,22 +195,3 @@ struct DatabaseClientTests {
await dbs.shutdownAsync()
}
}
struct EmployeeTestFactory {
let handler: (any Database) -> DatabaseClient.Employees
static var testCases: [Self] { [
.init(handler: { .live(database: $0) }),
.init(handler: { _ in .mock([]) })
] }
}
struct VendorTestFactory {
let handler: (any Database) -> (DatabaseClient.VendorBranches, DatabaseClient.Vendors)
static var testCases: [Self] { [
.init(handler: { (.live(database: $0), .live(database: $0)) }),
.init(handler: { _ in (.mock([]), .mock([])) })
] }
}