@@ -226,8 +226,8 @@ class FluentPostgreSQLTests: XCTestCase {
226226 try DefaultTest . prepare ( on: conn) . wait ( )
227227 _ = try DefaultTest ( ) . save ( on: conn) . wait ( )
228228 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 )
231231 }
232232
233233 func testGH30( ) throws {
@@ -411,6 +411,29 @@ class FluentPostgreSQLTests: XCTestCase {
411411 _ = try User . query ( on: conn) . filter ( \. id ~~ [ 1 , 2 ] ) . all ( ) . wait ( )
412412 _ = try User . query ( on: conn) . filter ( \. id ~~ [ 1 , 2 , 3 ] ) . all ( ) . wait ( )
413413 }
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+ }
414437
415438 static let allTests = [
416439 ( " testSchema " , testSchema) ,
@@ -437,6 +460,7 @@ class FluentPostgreSQLTests: XCTestCase {
437460 ( " testDocs_type " , testDocs_type) ,
438461 ( " testContains " , testContains) ,
439462 ( " testEmptySubset " , testEmptySubset) ,
463+ ( " testSort " , testSort) ,
440464 ]
441465}
442466
0 commit comments