Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #file usage for 5.3 #2411

Merged
merged 1 commit into from Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/XCTVapor/XCTApplication.swift
Expand Up @@ -104,7 +104,7 @@ extension XCTApplicationTester {
_ path: String,
headers: HTTPHeaders = [:],
body: ByteBuffer? = nil,
file: StaticString = (#file),
file: StaticString = #file,
line: UInt = #line,
beforeRequest: (inout XCTHTTPRequest) throws -> () = { _ in },
afterResponse: (XCTHTTPResponse) throws -> () = { _ in }
Expand All @@ -120,7 +120,7 @@ extension XCTApplicationTester {
let response = try self.performTest(request: request)
try afterResponse(response)
} catch {
XCTFail("\(error)", file: file, line: line)
XCTFail("\(error)", file: (file), line: line)
throw error
}
return self
Expand Down
9 changes: 5 additions & 4 deletions Sources/XCTVapor/XCTHTTPResponse.swift
Expand Up @@ -42,7 +42,7 @@ extension Response.Body {
public func XCTAssertContent<D>(
_ type: D.Type,
_ res: XCTHTTPResponse,
file: StaticString = (#file),
file: StaticString = #file,
line: UInt = #line,
_ closure: (D) -> ()
)
Expand All @@ -57,11 +57,12 @@ public func XCTAssertContent<D>(
let content = try decoder.decode(D.self, from: res.body, headers: res.headers)
closure(content)
} catch {
XCTFail("could not decode body: \(error)", file: file, line: line)
XCTFail("could not decode body: \(error)", file: (file), line: line)
}
}

public func XCTAssertContains(_ haystack: String?, _ needle: String?, file: StaticString = (#file), line: UInt = #line) {
public func XCTAssertContains(_ haystack: String?, _ needle: String?, file: StaticString = #file, line: UInt = #line) {
let file = (file)
switch (haystack, needle) {
case (.some(let haystack), .some(let needle)):
XCTAssert(haystack.contains(needle), "\(haystack) does not contain \(needle)", file: file, line: line)
Expand All @@ -74,7 +75,7 @@ public func XCTAssertContains(_ haystack: String?, _ needle: String?, file: Stat
}
}

public func XCTAssertEqualJSON<T>(_ data: String?, _ test: T, file: StaticString = (#file), line: UInt = #line)
public func XCTAssertEqualJSON<T>(_ data: String?, _ test: T, file: StaticString = #file, line: UInt = #line)
where T: Codable & Equatable
{
guard let data = data else {
Expand Down
3 changes: 2 additions & 1 deletion Tests/VaporTests/ErrorTests.swift
Expand Up @@ -154,9 +154,10 @@ final class ErrorTests: XCTestCase {
func XCTAssertContains(
_ haystack: String?,
_ needle: String,
file: StaticString = (#file),
file: StaticString = #file,
line: UInt = #line
) {
let file = (file)
guard let haystack = haystack else {
XCTFail("\(needle) not found in: nil", file: file, line: line)
return
Expand Down
8 changes: 4 additions & 4 deletions Tests/VaporTests/PasswordTests.swift
Expand Up @@ -82,7 +82,7 @@ final class PasswordTests: XCTestCase {
private func assertAsyncApplicationPasswordVerifies(
_ provider: Application.Passwords.Provider,
on app: Application,
file: StaticString = (#file),
file: StaticString = #file,
line: UInt = #line
) throws {
app.passwords.use(provider)
Expand All @@ -97,13 +97,13 @@ final class PasswordTests: XCTestCase {
.verify("vapor", created: asyncHash)
.wait()

XCTAssertTrue(asyncVerifiy, file: file, line: line)
XCTAssertTrue(asyncVerifiy, file: (file), line: line)
}

private func assertAsyncRequestPasswordVerifies(
_ provider: Application.Passwords.Provider,
on app: Application,
file: StaticString = (#file),
file: StaticString = #file,
line: UInt = #line
) throws {
app.passwords.use(provider)
Expand All @@ -122,7 +122,7 @@ final class PasswordTests: XCTestCase {
}

try app.test(.GET, "test", afterResponse: { res in
XCTAssertEqual(res.body.string, "true", file: file, line: line)
XCTAssertEqual(res.body.string, "true", file: (file), line: line)
})
}
}
6 changes: 4 additions & 2 deletions Tests/VaporTests/ValidationTests.swift
Expand Up @@ -329,9 +329,10 @@ private func assert<T>(
_ data: T,
fails validator: Validator<T>,
_ description: String,
file: StaticString = (#file),
file: StaticString = #file,
line: UInt = #line
) {
let file = (file)
let result = validator.validate(data)
XCTAssert(result.isFailure, result.successDescription ?? "n/a", file: file, line: line)
XCTAssertEqual(description, result.failureDescription ?? "n/a", file: file, line: line)
Expand All @@ -340,9 +341,10 @@ private func assert<T>(
private func assert<T>(
_ data: T,
passes validator: Validator<T>,
file: StaticString = (#file),
file: StaticString = #file,
line: UInt = #line
) {
let file = (file)
let result = validator.validate(data)
XCTAssert(!result.isFailure, result.failureDescription ?? "n/a", file: file, line: line)
}
Expand Down