diff options
Diffstat (limited to 'Frameworks/PostgresKit')
-rw-r--r-- | Frameworks/PostgresKit/Tests/PGPostgresIntegrationTestCase.m | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Frameworks/PostgresKit/Tests/PGPostgresIntegrationTestCase.m b/Frameworks/PostgresKit/Tests/PGPostgresIntegrationTestCase.m index 96de8a40..231e1bfa 100644 --- a/Frameworks/PostgresKit/Tests/PGPostgresIntegrationTestCase.m +++ b/Frameworks/PostgresKit/Tests/PGPostgresIntegrationTestCase.m @@ -35,6 +35,8 @@ static NSString *PGTestDatabasePassword = @"pgkit"; static NSUInteger PGTestDatabasePort = 5432; +static double PGTestConnectionTimeout = 0.2; + @interface PGPostgresIntegrationTestCase () - (void)_establishConnection; @@ -72,8 +74,20 @@ static NSUInteger PGTestDatabasePort = 5432; exit(1); } + NSDate *startDate = [NSDate date]; + do { sleep(0.1); + + if([[NSDate date] timeIntervalSinceDate:startDate] > PGTestConnectionTimeout) { + XCTFail(@"Failed to connect to database after %f seconds. Host:%@ Database:%@ User:%@ Password:%@", + PGTestConnectionTimeout, + PGTestDatabaseHost, + PGTestDatabaseName, + PGTestDatabaseUser, + PGTestDatabasePassword); + exit(1); + } } while (![_connection isConnected]); } |