Skip to content

Commit

Permalink
Fix filemiddleware tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Mar 1, 2024
1 parent 0448c63 commit 5928003
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Tests/HummingbirdTests/FileMiddlewareTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ class HummingbirdFilesTests: XCTestCase {
router.middlewares.add(HBFileMiddleware("."))
let app = HBApplication(responder: router.buildResponder())

let filename = "\(#function).jpg"
let text = "Test file contents"
let data = Data(text.utf8)
let fileURL = URL(fileURLWithPath: "\(#function).jpg")
let fileURL = URL(fileURLWithPath: filename)
XCTAssertNoThrow(try data.write(to: fileURL))
defer { XCTAssertNoThrow(try FileManager.default.removeItem(at: fileURL)) }

try await app.test(.router) { client in
try await client.XCTExecute(uri: "/test.jpg", method: .get) { response in
try await client.XCTExecute(uri: filename, method: .get) { response in
XCTAssertEqual(String(buffer: response.body), text)
XCTAssertEqual(response.headers[.contentType], "image/jpeg")
}
Expand Down

0 comments on commit 5928003

Please sign in to comment.