Skip to content

Commit

Permalink
Tweak test to remove need for a platform conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynne committed Sep 15, 2023
1 parent add2b50 commit 6086f3f
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions Tests/SQLiteNIOTests/SQLiteCustomFunctionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class DatabaseFunctionTests: XCTestCase {
let conn = try SQLiteConnection.open(storage: .memory, threadPool: self.threadPool, on: self.eventLoop).wait()
defer { try! conn.close().wait() }
let fn = SQLiteCustomFunction("f") { _ in
throw NSError(domain: "CustomErrorDomain", code: 123, userInfo: [NSLocalizedDescriptionKey: "custom error message"])
throw NSError(domain: "CustomErrorDomain", code: 123, userInfo: [NSLocalizedDescriptionKey: "custom error message", NSLocalizedFailureReasonErrorKey: "custom error message"])
}

try conn.install(customFunction: fn).wait()
Expand All @@ -324,15 +324,10 @@ class DatabaseFunctionTests: XCTestCase {
_ = try conn.query("SELECT f()").wait()
XCTFail("Expected Error")
} catch let error as SQLiteError {

XCTAssertEqual(error.reason, .error)
XCTAssertTrue(error.message.contains("CustomErrorDomain"))
XCTAssertTrue(error.message.contains("123"))
#if os(Linux)
XCTAssertTrue(error.message.contains("(null)"), "expected '\(error.message)' to contain '(null)'")
#else
XCTAssertTrue(error.message.contains("custom error message"), "expected '\(error.message)' to contain 'custom error message'")
#endif
}
}

Expand Down

0 comments on commit 6086f3f

Please sign in to comment.