aboutsummaryrefslogtreecommitdiffstats
path: root/UnitTests/mcpKitTest.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-11-13 23:35:07 +0000
committerstuconnolly <stuart02@gmail.com>2009-11-13 23:35:07 +0000
commit8baab51469e6fe1ea62ce9203d8ef2fe643879d7 (patch)
tree07126df856a05499c35a8ab3f5792dc7126d3c9b /UnitTests/mcpKitTest.m
parentedcb8806b64a017bb25a0d47b2cd8ba4598ce39d (diff)
downloadsequelpro-8baab51469e6fe1ea62ce9203d8ef2fe643879d7.tar.gz
sequelpro-8baab51469e6fe1ea62ce9203d8ef2fe643879d7.tar.bz2
sequelpro-8baab51469e6fe1ea62ce9203d8ef2fe643879d7.zip
Tidy up and fix unit tests.
Diffstat (limited to 'UnitTests/mcpKitTest.m')
-rw-r--r--UnitTests/mcpKitTest.m62
1 files changed, 30 insertions, 32 deletions
diff --git a/UnitTests/mcpKitTest.m b/UnitTests/mcpKitTest.m
index 8af68c64..49c02eb8 100644
--- a/UnitTests/mcpKitTest.m
+++ b/UnitTests/mcpKitTest.m
@@ -20,7 +20,8 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// More info at <http://code.google.com/p/sequel-pro/>
-//
+
+#import <MCPKit/MCPKit.h>
#import "mcpKitTest.h"
@@ -28,58 +29,55 @@
- (void)setUp
{
- // for now, we try an find the following database in the local connection
- // if the connection fails for any reasons, tests are not run.
+ // For now, we try an find the following database in the local connection.
+ // If the connection fails for any reasons, tests are not run.
// http://downloads.mysql.com/docs/sakila-db.zip
- // set up a user called 'sakila' with no password that has all privs on the
- // database 'sakila'
+ //
+ // Set up a user called 'sakila' with no password that has all privs on the
+ // database 'sakila'.
+
+ connection = [[MCPConnection alloc] initToSocket:@"/var/mysql/mysql.sock" withLogin:@"sakila"];
- mySQLConnection = [[MCPConnection alloc] initToSocket:@"/var/mysql/mysql.sock"
- withLogin:@"sakila"
- password:@""];
+ // Set the 'sakila' user's password
+ [connection setPassword:@""];
- if ( ![mySQLConnection isConnected] ) {
- [mySQLConnection dealloc];
- mySQLConnection = nil;
- STFail(@"unable to connect with server. No tests run!");
- } else {
- if ( ! [mySQLConnection selectDB:@"sakila"]) {
- [mySQLConnection dealloc];
- mySQLConnection = nil;
- STFail(@"unable to use `sakila` database. No tests run!");
+ if (![connection isConnected]) {
+ [connection dealloc];
+ connection = nil;
+ STFail(@"Error connecting to database server. No tests were run.");
+ }
+ else {
+ if (![connection selectDB:@"sakila"]) {
+ [connection dealloc];
+ connection = nil;
+ STFail(@"Error selecting database 'sakila'. No tests were run.");
}
}
}
- (void)tearDown
{
- if( mySQLConnection != nil ) {
- [mySQLConnection disconnect];
- [mySQLConnection dealloc];
+ if (connection != nil) {
+ [connection disconnect];
+ [connection dealloc];
}
}
- (void)testServerVersion
{
- if( mySQLConnection == nil )
- return;
+ if (connection == nil) return;
- STAssertTrue( [mySQLConnection serverMajorVersion] != 0, @"server version");
- STAssertTrue( [mySQLConnection serverMajorVersion] != 0, @"server version");
+ STAssertTrue([connection serverMajorVersion] != 0, @"server version");
+ STAssertTrue([connection serverMajorVersion] != 0, @"server version");
}
-
- (void)testTableList
{
- if( mySQLConnection == nil )
- return;
-
- MCPResult *theResult;
+ if (connection == nil) return;
- NSString *pQuery = @"SELECT * FROM actor";
- theResult = [mySQLConnection queryString:pQuery];
+ MCPResult *queryResult = [connection queryString:@"SELECT * FROM actor"];
- STAssertEquals([theResult numOfRows],(my_ulonglong)200, @"actors table count" );
+ STAssertEquals([queryResult numOfRows], (my_ulonglong)200, @"actors table count");
}
@end