feat: Adds createFromCSV to create rooms in the database, properly handling delegating airflow to another room.
Some checks failed
CI / Linux Tests (push) Failing after 5m29s
Some checks failed
CI / Linux Tests (push) Failing after 5m29s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import App
|
||||
import CSVParser
|
||||
import DatabaseClient
|
||||
import Dependencies
|
||||
import Fluent
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import CSVParser
|
||||
import Dependencies
|
||||
import FileClient
|
||||
import Foundation
|
||||
import ManualDCore
|
||||
import Parsing
|
||||
@@ -63,6 +65,31 @@ struct RoomTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
func createFromCSV() async throws {
|
||||
try await withTestUserAndProject {
|
||||
$0.csvParser = .liveValue
|
||||
} operation: { _, project in
|
||||
@Dependency(\.csvParser) var csvParser
|
||||
@Dependency(\.database) var database
|
||||
@Dependency(\.fileClient) var fileClient
|
||||
|
||||
let csvPath = Bundle.module.path(forResource: "rooms", ofType: "csv")
|
||||
let csvFile = Room.CSV(file: try Data(contentsOf: URL(filePath: csvPath!)))
|
||||
let rows = try await csvParser.parseRooms(csvFile)
|
||||
print()
|
||||
print("ROWS: \(rows)")
|
||||
print()
|
||||
|
||||
let created = try await database.rooms.createFromCSV(project.id, rows)
|
||||
|
||||
print()
|
||||
print("CREATED: \(created)")
|
||||
print()
|
||||
#expect(created.count == rows.count)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
func notFound() async throws {
|
||||
try await withDatabase {
|
||||
@@ -157,4 +184,3 @@ struct RoomTests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user