Implemented the ArchiveController controller in the library target.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import Foundation
|
||||
import Hummingbird
|
||||
import HummingbirdTesting
|
||||
import Testing
|
||||
|
||||
@testable import DoxyLibrary
|
||||
|
||||
@Suite("ArchiveController", .tags(.controller))
|
||||
struct ArchiveControllerTests {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
private let decoder: JSONDecoder = .init()
|
||||
|
||||
@Test func xxx() async throws {
|
||||
// GIVEN
|
||||
let fileService = FileServiceMock(items: ["SomeArchive.doccarchive", "some-file.txt"])
|
||||
let router = Router()
|
||||
|
||||
ArchiveController("/path/to/archives/folder", fileService: fileService)
|
||||
.register(to: router)
|
||||
|
||||
let app = Application(router: router)
|
||||
|
||||
// WHEN
|
||||
// THEN
|
||||
try await app.test(.router) { client in
|
||||
try await client.execute(uri: "/archives", method: .get) { response in
|
||||
let archiveList = try decoder.decode(ArchiveList.self, from: response.body)
|
||||
|
||||
#expect(response.status == .ok)
|
||||
#expect(archiveList.archives == ["SomeArchive.doccarchive"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test func yyy() async throws {
|
||||
// GIVEN
|
||||
let fileService = FileServiceMock(error: .folderNotFound)
|
||||
let router = Router()
|
||||
|
||||
ArchiveController("/path/to/archives/folder", fileService: fileService)
|
||||
.register(to: router)
|
||||
|
||||
let app = Application(router: router)
|
||||
|
||||
// WHEN
|
||||
// THEN
|
||||
try await app.test(.router) { client in
|
||||
try await client.execute(uri: "/archives", method: .get) { response in
|
||||
#expect(response.status == .ok)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user