aboutsummaryrefslogtreecommitdiffstats
path: root/UnitTests
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
parentedcb8806b64a017bb25a0d47b2cd8ba4598ce39d (diff)
downloadsequelpro-8baab51469e6fe1ea62ce9203d8ef2fe643879d7.tar.gz
sequelpro-8baab51469e6fe1ea62ce9203d8ef2fe643879d7.tar.bz2
sequelpro-8baab51469e6fe1ea62ce9203d8ef2fe643879d7.zip
Tidy up and fix unit tests.
Diffstat (limited to 'UnitTests')
-rw-r--r--UnitTests/mcpKitTest.h6
-rw-r--r--UnitTests/mcpKitTest.m62
-rw-r--r--UnitTests/stringCategoryAdditionsTest.h1
-rw-r--r--UnitTests/stringCategoryAdditionsTest.m10
4 files changed, 39 insertions, 40 deletions
diff --git a/UnitTests/mcpKitTest.h b/UnitTests/mcpKitTest.h
index 8e5fd508..14f263bd 100644
--- a/UnitTests/mcpKitTest.h
+++ b/UnitTests/mcpKitTest.h
@@ -20,14 +20,14 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// More info at <http://code.google.com/p/sequel-pro/>
-//
#import <SenTestingKit/SenTestingKit.h>
-#import <MCPKit/MCPKit.h>
+
+@class MCPConnection;
@interface mcpKitTest : SenTestCase
{
- MCPConnection *mySQLConnection;
+ MCPConnection *connection;
}
@end
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
diff --git a/UnitTests/stringCategoryAdditionsTest.h b/UnitTests/stringCategoryAdditionsTest.h
index 2fc611be..d995a29e 100644
--- a/UnitTests/stringCategoryAdditionsTest.h
+++ b/UnitTests/stringCategoryAdditionsTest.h
@@ -20,7 +20,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// More info at <http://code.google.com/p/sequel-pro/>
-//
#import <SenTestingKit/SenTestingKit.h>
diff --git a/UnitTests/stringCategoryAdditionsTest.m b/UnitTests/stringCategoryAdditionsTest.m
index cff13ac9..11a4a49b 100644
--- a/UnitTests/stringCategoryAdditionsTest.m
+++ b/UnitTests/stringCategoryAdditionsTest.m
@@ -20,7 +20,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// More info at <http://code.google.com/p/sequel-pro/>
-//
#import "stringCategoryAdditionsTest.h"
#import "SPStringAdditions.h"
@@ -40,14 +39,17 @@
- (void)testStringByRemovingCharactersInSet
{
NSCharacterSet *junk = [NSCharacterSet characterSetWithCharactersInString:@"abc',ü"];
+
NSString *s = @"this is big, crazy st'ring";
NSString *expect = @"this is ig rzy string";
- STAssertEqualObjects( [s stringByRemovingCharactersInSet:junk], expect, @"stringByRemovingCharactersInSet" );
- // check UTF
+ STAssertEqualObjects([s stringByRemovingCharactersInSet:junk], expect, @"stringByRemovingCharactersInSet");
+
+ // Check UTF
s = @"In der Kürze liegt die Würz";
expect = @"In der Krze liegt die Wrz";
- STAssertEqualObjects( [s stringByRemovingCharactersInSet:junk], expect, @"stringByRemovingCharactersInSet" );
+
+ STAssertEqualObjects([s stringByRemovingCharactersInSet:junk], expect, @"stringByRemovingCharactersInSet");
}
@end