Skip to content

Commit

Permalink
Fix spurious test failures with Swift 6 on Linux (#78)
Browse files Browse the repository at this point in the history
Fix spurious test failures with Swift 6 on Linux by eliminating a redundant test and using the one that already accounts for the precision issue.
  • Loading branch information
gwynne authored Dec 8, 2024
1 parent 0c6a711 commit 7353cca
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions Tests/SQLiteNIOTests/SQLiteNIOTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,8 @@ final class SQLiteNIOTests: XCTestCase {

func testTimestampStorage() async throws {
try await withOpenedConnection { conn in
let date = Date()
let rows = try await conn.query("SELECT ? as date", [date.sqliteData!])
XCTAssertEqual(rows.first?.column("date"), .float(date.timeIntervalSince1970))
XCTAssertEqual(rows.first?.column("date").flatMap(Date.init(sqliteData:))?.description, date.description)
XCTAssertEqual(rows.first?.column("date").flatMap(Date.init(sqliteData:)), date)
XCTAssertEqual(rows.first?.column("date").flatMap(Date.init(sqliteData:))?.timeIntervalSinceReferenceDate, date.timeIntervalSinceReferenceDate)
}
}

func testTimestampStorageRoundToMicroseconds() async throws {
try await withOpenedConnection { conn in
// Test value that when read back out of sqlite results in 7 decimal places that we need to round to microseconds
// When the value is read back out of sqlite, it will have only microsecond precision, make sure we use a Date with
// the same limit or else the test will fail.
let date = Date(timeIntervalSinceReferenceDate: 689658914.293192)
let rows = try await conn.query("SELECT ? as date", [date.sqliteData!])
XCTAssertEqual(rows.first?.column("date"), .float(date.timeIntervalSince1970))
Expand Down

0 comments on commit 7353cca

Please sign in to comment.