Skip to content

Commit 8fece72

Browse files
committed
create a constant for the UUID used in tests
1 parent 7715f7d commit 8fece72

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

Tests/SQLiteTests/QueryIntegrationTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ class QueryIntegrationTests: SQLiteTestCase {
8181
})
8282

8383
let value1 = TestCodable(int: 1, string: "2", bool: true, float: 3, double: 4,
84-
date: Date(timeIntervalSince1970: 0), uuid: UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!, optional: nil, sub: nil)
84+
date: Date(timeIntervalSince1970: 0), uuid: testUUIDValue, optional: nil, sub: nil)
8585
let value = TestCodable(int: 5, string: "6", bool: true, float: 7, double: 8,
86-
date: Date(timeIntervalSince1970: 5000), uuid: UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!, optional: "optional", sub: value1)
86+
date: Date(timeIntervalSince1970: 5000), uuid: testUUIDValue, optional: "optional", sub: value1)
8787
try db.run(table.insert(value))
8888

8989
let rows = try db.prepare(table)
@@ -95,7 +95,7 @@ class QueryIntegrationTests: SQLiteTestCase {
9595
XCTAssertEqual(values[0].float, 7)
9696
XCTAssertEqual(values[0].double, 8)
9797
XCTAssertEqual(values[0].date, Date(timeIntervalSince1970: 5000))
98-
XCTAssertEqual(values[0].uuid, UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!)
98+
XCTAssertEqual(values[0].uuid, testUUIDValue)
9999
XCTAssertEqual(values[0].optional, "optional")
100100
XCTAssertEqual(values[0].sub?.int, 1)
101101
XCTAssertEqual(values[0].sub?.string, "2")

Tests/SQLiteTests/QueryTests.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class QueryTests: XCTestCase {
279279
func test_insert_encodable() throws {
280280
let emails = Table("emails")
281281
let value = TestCodable(int: 1, string: "2", bool: true, float: 3, double: 4,
282-
date: Date(timeIntervalSince1970: 0), uuid: UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!, optional: nil, sub: nil)
282+
date: Date(timeIntervalSince1970: 0), uuid: testUUIDValue, optional: nil, sub: nil)
283283
let insert = try emails.insert(value)
284284
assertSQL(
285285
"""
@@ -294,9 +294,9 @@ class QueryTests: XCTestCase {
294294
func test_insert_encodable_with_nested_encodable() throws {
295295
let emails = Table("emails")
296296
let value1 = TestCodable(int: 1, string: "2", bool: true, float: 3, double: 4,
297-
date: Date(timeIntervalSince1970: 0), uuid: UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!, optional: nil, sub: nil)
297+
date: Date(timeIntervalSince1970: 0), uuid: testUUIDValue, optional: nil, sub: nil)
298298
let value = TestCodable(int: 1, string: "2", bool: true, float: 3, double: 4,
299-
date: Date(timeIntervalSince1970: 0), uuid: UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!, optional: "optional", sub: value1)
299+
date: Date(timeIntervalSince1970: 0), uuid: testUUIDValue, optional: "optional", sub: value1)
300300
let insert = try emails.insert(value)
301301
let encodedJSON = try JSONEncoder().encode(value1)
302302
let encodedJSONString = String(data: encodedJSON, encoding: .utf8)!
@@ -350,7 +350,7 @@ class QueryTests: XCTestCase {
350350
let emails = Table("emails")
351351
let string = Expression<String>("string")
352352
let value = TestCodable(int: 1, string: "2", bool: true, float: 3, double: 4,
353-
date: Date(timeIntervalSince1970: 0), uuid: UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!, optional: nil, sub: nil)
353+
date: Date(timeIntervalSince1970: 0), uuid: testUUIDValue, optional: nil, sub: nil)
354354
let insert = try emails.upsert(value, onConflictOf: string)
355355
assertSQL(
356356
"""
@@ -366,11 +366,11 @@ class QueryTests: XCTestCase {
366366
func test_insert_many_encodable() throws {
367367
let emails = Table("emails")
368368
let value1 = TestCodable(int: 1, string: "2", bool: true, float: 3, double: 4,
369-
date: Date(timeIntervalSince1970: 0), uuid: UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!, optional: nil, sub: nil)
369+
date: Date(timeIntervalSince1970: 0), uuid: testUUIDValue, optional: nil, sub: nil)
370370
let value2 = TestCodable(int: 2, string: "3", bool: true, float: 3, double: 5,
371-
date: Date(timeIntervalSince1970: 0), uuid: UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!, optional: nil, sub: nil)
371+
date: Date(timeIntervalSince1970: 0), uuid: testUUIDValue, optional: nil, sub: nil)
372372
let value3 = TestCodable(int: 3, string: "4", bool: true, float: 3, double: 6,
373-
date: Date(timeIntervalSince1970: 0), uuid: UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!, optional: nil, sub: nil)
373+
date: Date(timeIntervalSince1970: 0), uuid: testUUIDValue, optional: nil, sub: nil)
374374
let insert = try emails.insertMany([value1, value2, value3])
375375
assertSQL(
376376
"""
@@ -399,7 +399,7 @@ class QueryTests: XCTestCase {
399399
func test_update_encodable() throws {
400400
let emails = Table("emails")
401401
let value = TestCodable(int: 1, string: "2", bool: true, float: 3, double: 4,
402-
date: Date(timeIntervalSince1970: 0), uuid: UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!, optional: nil, sub: nil)
402+
date: Date(timeIntervalSince1970: 0), uuid: testUUIDValue, optional: nil, sub: nil)
403403
let update = try emails.update(value)
404404
assertSQL(
405405
"""
@@ -413,9 +413,9 @@ class QueryTests: XCTestCase {
413413
func test_update_encodable_with_nested_encodable() throws {
414414
let emails = Table("emails")
415415
let value1 = TestCodable(int: 1, string: "2", bool: true, float: 3, double: 4,
416-
date: Date(timeIntervalSince1970: 0), uuid: UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!, optional: nil, sub: nil)
416+
date: Date(timeIntervalSince1970: 0), uuid: testUUIDValue, optional: nil, sub: nil)
417417
let value = TestCodable(int: 1, string: "2", bool: true, float: 3, double: 4,
418-
date: Date(timeIntervalSince1970: 0), uuid: UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!, optional: nil, sub: value1)
418+
date: Date(timeIntervalSince1970: 0), uuid: testUUIDValue, optional: nil, sub: value1)
419419
let update = try emails.update(value)
420420

421421
// NOTE: As Linux JSON decoding doesn't order keys the same way, we need to check prefix, suffix,

Tests/SQLiteTests/TestHelpers.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ let stringOptional = Expression<String?>("stringOptional")
9898
let uuid = Expression<UUID>("uuid")
9999
let uuidOptional = Expression<UUID?>("uuidOptional")
100100

101+
let testUUIDValue = UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!
102+
101103
func assertSQL(_ expression1: @autoclosure () -> String, _ expression2: @autoclosure () -> Expressible,
102104
file: StaticString = #file, line: UInt = #line) {
103105
XCTAssertEqual(expression1(), expression2().asSQL(), file: file, line: line)

0 commit comments

Comments
 (0)