aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/PostgresKit/Tests
diff options
context:
space:
mode:
authorMarius Ursache <marius@marius.me.uk>2016-03-01 11:08:27 +1100
committerMarius Ursache <marius@marius.me.uk>2016-03-01 11:08:27 +1100
commitcbbd6e05d65015d26f90e001cabcc5857c9b2134 (patch)
tree25e1db44f0d1c54f628f5663e83ed8e9d013bea5 /Frameworks/PostgresKit/Tests
parent7887ad6932b02ca149520b1624608504da3494bf (diff)
downloadsequelpro-cbbd6e05d65015d26f90e001cabcc5857c9b2134.tar.gz
sequelpro-cbbd6e05d65015d26f90e001cabcc5857c9b2134.tar.bz2
sequelpro-cbbd6e05d65015d26f90e001cabcc5857c9b2134.zip
Failed postgres tests if cannot connect to host/db
Otherwise the tests will just wait indefinitely
Diffstat (limited to 'Frameworks/PostgresKit/Tests')
-rw-r--r--Frameworks/PostgresKit/Tests/PGPostgresIntegrationTestCase.m14
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]);
}