@@ -226,8 +226,8 @@ class FluentPostgreSQLTests: XCTestCase {
226
226
try DefaultTest . prepare ( on: conn) . wait ( )
227
227
_ = try DefaultTest ( ) . save ( on: conn) . wait ( )
228
228
let fetched = try DefaultTest . query ( on: conn) . first ( ) . wait ( ) !
229
- // within 10 seconds
230
- XCTAssertEqual ( Date ( ) . timeIntervalSinceReferenceDate, fetched. date!. timeIntervalSinceReferenceDate, accuracy: 15 )
229
+ // within 1 minute
230
+ XCTAssertEqual ( Date ( ) . timeIntervalSinceReferenceDate, fetched. date!. timeIntervalSinceReferenceDate, accuracy: 60 )
231
231
}
232
232
233
233
func testGH30( ) throws {
@@ -411,6 +411,29 @@ class FluentPostgreSQLTests: XCTestCase {
411
411
_ = try User . query ( on: conn) . filter ( \. id ~~ [ 1 , 2 ] ) . all ( ) . wait ( )
412
412
_ = try User . query ( on: conn) . filter ( \. id ~~ [ 1 , 2 , 3 ] ) . all ( ) . wait ( )
413
413
}
414
+
415
+ func testSort( ) throws {
416
+ struct Planet : PostgreSQLModel , PostgreSQLMigration , Equatable {
417
+ var id : Int ?
418
+ var name : String
419
+ init ( id: Int ? = nil , name: String ) {
420
+ self . id = id
421
+ self . name = name
422
+ }
423
+ }
424
+ let conn = try benchmarker. pool. requestConnection ( ) . wait ( )
425
+ defer { benchmarker. pool. releaseConnection ( conn) }
426
+ try Planet . prepare ( on: conn) . wait ( )
427
+ defer { _ = try ? Planet . revert ( on: conn) . wait ( ) }
428
+
429
+ _ = try Planet ( name: " Jupiter " ) . save ( on: conn) . wait ( )
430
+ _ = try Planet ( name: " Earth " ) . save ( on: conn) . wait ( )
431
+ _ = try Planet ( name: " Mars " ) . save ( on: conn) . wait ( )
432
+
433
+ let unordered = try Planet . query ( on: conn) . all ( ) . wait ( )
434
+ let ordered = try Planet . query ( on: conn) . sort ( \. name) . all ( ) . wait ( )
435
+ XCTAssertNotEqual ( unordered, ordered)
436
+ }
414
437
415
438
static let allTests = [
416
439
( " testSchema " , testSchema) ,
@@ -437,6 +460,7 @@ class FluentPostgreSQLTests: XCTestCase {
437
460
( " testDocs_type " , testDocs_type) ,
438
461
( " testContains " , testContains) ,
439
462
( " testEmptySubset " , testEmptySubset) ,
463
+ ( " testSort " , testSort) ,
440
464
]
441
465
}
442
466
0 commit comments