Skip to content

Commit

Permalink
Fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTim committed May 7, 2024
1 parent 1f1ccf9 commit c98f0bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Tests/VaporTests/FileTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ final class FileTests: XCTestCase {
let path = #filePath.split(separator: "/").dropLast().joined(separator: "/")
app.middleware.use(FileMiddleware(publicDirectory: "/" + path))

try await app.test(.GET, "/Utilities/foo%20bar.html") { res async in
try await app.testable(method: .running(port: 0)).test(.GET, "/Utilities/foo%20bar.html") { res async in
XCTAssertEqual(res.status, .ok)
XCTAssertEqual(res.body.string, "<h1>Hello</h1>\n")
}
Expand All @@ -370,7 +370,7 @@ final class FileTests: XCTestCase {
let path = #filePath.split(separator: "/").dropLast().joined(separator: "/")
app.middleware.use(FileMiddleware(publicDirectory: "/" + path))

try await app.test(.GET, "%2e%2e/VaporTests/Utilities/foo.txt") { res async in
try await app.testable(method: .running(port: 0)).test(.GET, "%2e%2e/VaporTests/Utilities/foo.txt") { res async in
XCTAssertEqual(res.status, .forbidden)
}.test(.GET, "Utilities/foo.txt") { res async in
XCTAssertEqual(res.status, .ok)
Expand All @@ -385,7 +385,7 @@ final class FileTests: XCTestCase {
let path = #filePath.split(separator: "/").dropLast().joined(separator: "/")
app.middleware.use(FileMiddleware(publicDirectory: "/" + path, defaultFile: "index.html"))

try await app.test(.GET, "Utilities/") { res async in
try await app.testable(method: .running(port: 0)).test(.GET, "Utilities/") { res async in
XCTAssertEqual(res.status, .ok)
XCTAssertEqual(res.body.string, "<h1>Root Default</h1>\n")
}.test(.GET, "Utilities/SubUtilities/") { res async in
Expand All @@ -401,7 +401,7 @@ final class FileTests: XCTestCase {
let path = #filePath.split(separator: "/").dropLast().joined(separator: "/")
app.middleware.use(FileMiddleware(publicDirectory: "/" + path, defaultFile: "/Utilities/index.html"))

try await app.test(.GET, "Utilities/") { res async in
try await app.testable(method: .running(port: 0)).test(.GET, "Utilities/") { res async in
XCTAssertEqual(res.status, .ok)
XCTAssertEqual(res.body.string, "<h1>Root Default</h1>\n")
}.test(.GET, "Utilities/SubUtilities/") { res async in
Expand Down
4 changes: 2 additions & 2 deletions Tests/VaporTests/MiddlewareTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ final class MiddlewareTests: XCTestCase {
defer { app.shutdown() }
app.middleware.use(fileMiddleware)

try await app.testable().test(.GET, "/foo.txt") { result in
try await app.testable(method: .running(port: 0)).test(.GET, "/foo.txt") { result async in
XCTAssertEqual(result.status, .ok)
XCTAssertEqual(result.body.string, "bar\n")
}
Expand All @@ -135,7 +135,7 @@ final class MiddlewareTests: XCTestCase {
defer { app.shutdown() }
app.middleware.use(fileMiddleware)

try await app.testable().test(.GET, "/index.html") { result in
try await app.testable(method: .running(port: 0)).test(.GET, "/index.html") { result async in
XCTAssertEqual(result.status, .ok)
XCTAssertEqual(result.body.string, "<h1>Subdirectory Default</h1>\n")
}
Expand Down

0 comments on commit c98f0bf

Please sign in to comment.