feat: Adds script to generate database seeded values and removes old mock storage.
This commit is contained in:
@@ -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([])) })
|
||||
] }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user