aboutsummaryrefslogtreecommitdiffstats
path: root/UnitTests
diff options
context:
space:
mode:
Diffstat (limited to 'UnitTests')
-rw-r--r--UnitTests/SPDatabaseCopyTest.m29
-rw-r--r--UnitTests/SPDatabaseRenameTest.m25
-rw-r--r--UnitTests/SPTableCopyTest.m35
3 files changed, 37 insertions, 52 deletions
diff --git a/UnitTests/SPDatabaseCopyTest.m b/UnitTests/SPDatabaseCopyTest.m
index df4807b9..358e0c1e 100644
--- a/UnitTests/SPDatabaseCopyTest.m
+++ b/UnitTests/SPDatabaseCopyTest.m
@@ -29,34 +29,27 @@
#import "SPDatabaseCopyTest.h"
#import "SPDatabaseCopy.h"
#import "SPTableCopy.h"
-#import "MCPConnection.h"
-#import "SPDatabaseInfo.h"
#import "SPLogger.h"
@implementation SPDatabaseCopyTest
-- (SPDatabaseCopy *) getDatabaseCopyFixture {
- SPDatabaseCopy *dbCopy = [[SPDatabaseCopy alloc] init];
- return [dbCopy autorelease];
-}
-
-- (SPTableCopy *) getTableCopyFixture {
- SPTableCopy *tableCopy = [[SPTableCopy alloc] init];
- return [tableCopy autorelease];
+- (SPDatabaseCopy *)getDatabaseCopyFixture
+{
+ return [[[SPDatabaseCopy alloc] init] autorelease];
}
-- (id) getMockConnection {
- id mockConnection = [OCMockObject niceMockForClass:[MCPConnection class]];
- return mockConnection;
+- (SPTableCopy *)getTableCopyFixture
+{
+ return [[[SPTableCopy alloc] init] autorelease];
}
-- (id) getMockDBInfo {
- id mockDBInfo = [OCMockObject niceMockForClass:[SPDatabaseInfo class]];
- return mockDBInfo;
+- (id)getMockConnection
+{
+ return [OCMockObject niceMockForClass:[SPMySQLConnection class]];
}
-- (void)testCopyDatabase {
-
+- (void)testCopyDatabase
+{
SPDatabaseCopy *dbCopy = [self getDatabaseCopyFixture];
id mockConnection = [self getMockConnection];
[[mockConnection expect] queryString:@"CREATE DATABASE `target_name`"];
diff --git a/UnitTests/SPDatabaseRenameTest.m b/UnitTests/SPDatabaseRenameTest.m
index 335e9f34..c0956262 100644
--- a/UnitTests/SPDatabaseRenameTest.m
+++ b/UnitTests/SPDatabaseRenameTest.m
@@ -23,43 +23,28 @@
//
// More info at <http://code.google.com/p/sequel-pro/>
-#import <OCMock/OCMock.h>
-
#import "SPDatabaseRenameTest.h"
#import "SPDatabaseRename.h"
#import "SPTableCopy.h"
-#import "MCPConnection.h"
-#import "SPDatabaseInfo.h"
#import "SPLogger.h"
+#import <OCMock/OCMock.h>
+
@implementation SPDatabaseRenameTest
- (SPDatabaseRename *)getDatabaseRenameFixture
{
- SPDatabaseRename *dbRename = [[SPDatabaseRename alloc] init];
-
- return [dbRename autorelease];
+ return [[[SPDatabaseRename alloc] init] autorelease];
}
- (SPTableCopy *)getTableCopyFixture
{
- SPTableCopy *tableCopy = [[SPTableCopy alloc] init];
-
- return [tableCopy autorelease];
+ return [[[SPTableCopy alloc] init] autorelease];
}
- (id)getMockConnection
{
- id mockConnection = [OCMockObject niceMockForClass:[MCPConnection class]];
-
- return mockConnection;
-}
-
-- (id)getMockDBInfo
-{
- id mockDBInfo = [OCMockObject niceMockForClass:[SPDatabaseInfo class]];
-
- return mockDBInfo;
+ return [OCMockObject niceMockForClass:[SPMySQLConnection class]];
}
- (void)testRenameDatabase
diff --git a/UnitTests/SPTableCopyTest.m b/UnitTests/SPTableCopyTest.m
index f0e31c14..0d146827 100644
--- a/UnitTests/SPTableCopyTest.m
+++ b/UnitTests/SPTableCopyTest.m
@@ -23,47 +23,54 @@
//
// More info at <http://code.google.com/p/sequel-pro/>
-#import <OCMock/OCMock.h>
#import "SPTableCopy.h"
#import "SPTableCopyTest.h"
+#import <OCMock/OCMock.h>
+#import <SPMySQL/SPMySQL.h>
@implementation SPTableCopyTest
-- (id) getMockConnection {
- id mockConnection = [OCMockObject niceMockForClass:[MCPConnection class]];
- return [mockConnection autorelease];
+- (id)getMockConnection
+{
+ return [[OCMockObject niceMockForClass:[SPMySQLConnection class]] autorelease];
}
-- (id) getMockResult {
- id mockResult = [OCMockObject niceMockForClass:[MCPResult class]];
- return mockResult;
+- (id)getMockResult
+{
+ return [OCMockObject niceMockForClass:[SPMySQLResult class]];
}
-- (SPTableCopy *) getTableCopyFixture {
- SPTableCopy *tableCopy = [[SPTableCopy alloc] init];
- return [tableCopy autorelease];
+- (SPTableCopy *)getTableCopyFixture
+{
+ return [[[SPTableCopy alloc] init] autorelease];
}
-- (void)testCopyTableFromToWithData {
+- (void)testCopyTableFromToWithData
+{
id mockResult = [self getMockResult];
+
unsigned long long varOne = 1;
NSValue *valueOne = [NSValue value:&varOne withObjCType:@encode(__typeof__(varOne))];
BOOL varNo = NO;
+
NSValue *valueNo = [NSValue value:&varNo withObjCType:@encode(BOOL)];
NSArray *resultArray = [[NSArray alloc] initWithObjects:@"", @"CREATE TABLE `table_name` ()", nil];
- [[[mockResult expect] andReturnValue:valueOne] numOfRows];
- [[[mockResult expect] andReturn:resultArray] fetchRowAsArray];
+
+ [[[mockResult expect] andReturnValue:valueOne] numberOfRows];
+ [[[mockResult expect] andReturn:resultArray] getRowAsArray];
id mockConnection = [self getMockConnection];
+
[[[mockConnection expect] andReturn:mockResult] queryString:@"SHOW CREATE TABLE `source_db`.`table_name`"];
[[mockConnection expect] queryString:@"CREATE TABLE `target_db`.`table_name` ()"];
[[mockConnection expect] queryString:@"INSERT INTO `target_db`.`table_name` SELECT * FROM `source_db`.`table_name`"];
[[[mockConnection stub] andReturnValue:valueNo] queryErrored];
id tableCopy = [self getTableCopyFixture];
+
[tableCopy setConnection:mockConnection];
- [tableCopy copyTable: @"table_name" from: @"source_db" to: @"target_db" withContent: YES];
+ [tableCopy copyTable:@"table_name" from:@"source_db" to:@"target_db" withContent:YES];
[mockResult verify];
[mockConnection verify];
[resultArray release];