diff options
Diffstat (limited to 'UnitTests')
-rw-r--r-- | UnitTests/SPDatabaseCopyTest.h | 35 | ||||
-rw-r--r-- | UnitTests/SPDatabaseCopyTest.m | 91 | ||||
-rw-r--r-- | UnitTests/SPDatabaseInfoTest.h | 40 | ||||
-rw-r--r-- | UnitTests/SPDatabaseInfoTest.m | 84 | ||||
-rw-r--r-- | UnitTests/SPDatabaseRenameTest.h | 35 | ||||
-rw-r--r-- | UnitTests/SPDatabaseRenameTest.m | 91 | ||||
-rw-r--r-- | UnitTests/SPTableCopyTest.h | 37 | ||||
-rw-r--r-- | UnitTests/SPTableCopyTest.m | 72 |
8 files changed, 0 insertions, 485 deletions
diff --git a/UnitTests/SPDatabaseCopyTest.h b/UnitTests/SPDatabaseCopyTest.h deleted file mode 100644 index 641b3cdd..00000000 --- a/UnitTests/SPDatabaseCopyTest.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// $Id$ -// -// SPDatabaseCopyTest.h -// sequel-pro -// -// Created by David Rekowski -// Copyright (c) 2010 David Rekowski. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at <http://code.google.com/p/sequel-pro/> - -#define USE_APPLICATION_UNIT_TEST 1 - -#import <SenTestingKit/SenTestingKit.h> - -@interface SPDatabaseCopyTest : SenTestCase { -} -- (void) testCopyDatabase; -- (void) testCreateDatabase; - -@end diff --git a/UnitTests/SPDatabaseCopyTest.m b/UnitTests/SPDatabaseCopyTest.m deleted file mode 100644 index 593989de..00000000 --- a/UnitTests/SPDatabaseCopyTest.m +++ /dev/null @@ -1,91 +0,0 @@ -// -// $Id$ -// -// SPDatabaseCopyTest.m -// sequel-pro -// -// Created by David Rekowski -// Copyright (c) 2010 David Rekowski. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at <http://code.google.com/p/sequel-pro/> - -#import <OCMock/OCMock.h> -#import "SPAlertSheets.h" -#import "SPDatabaseCopyTest.h" -#import "SPDatabaseCopy.h" -#import "SPTableCopy.h" -#import "MCPConnection.h" -#import "SPDatabaseInfo.h" -#import "SPStringAdditions.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]; -} - -- (id) getMockConnection { - id mockConnection = [OCMockObject niceMockForClass:[MCPConnection class]]; - return mockConnection; -} - -- (id) getMockDBInfo { - id mockDBInfo = [OCMockObject niceMockForClass:[SPDatabaseInfo class]]; - return mockDBInfo; -} - -- (void) testCopyDatabase { - - SPDatabaseCopy *dbCopy = [self getDatabaseCopyFixture]; - id mockConnection = [self getMockConnection]; - [[mockConnection expect] queryString:@"CREATE DATABASE `target_name`"]; - [[mockConnection expect] listTablesFromDB:@"source_name"]; - [[[mockConnection stub] andReturn:[[NSArray alloc] init]] listTablesFromDB:@"source_name"]; - [dbCopy setConnection:mockConnection]; - - id mockDBInfo = [self getMockDBInfo]; - - BOOL varNo = NO; - BOOL varYes = YES; - [[[mockDBInfo expect] andReturnValue:[NSValue value:&varYes withObjCType:@encode(BOOL)]] databaseExists:@"source_name"]; - - [[[mockDBInfo expect] andReturnValue:[NSValue value:&varNo withObjCType:@encode(BOOL)]] databaseExists:@"target_name"]; - - [dbCopy setDbInfo:mockDBInfo]; - - NSString *source = [[NSString alloc] initWithString:@"source_name"]; - NSString *target = [[NSString alloc] initWithString:@"target_name"]; - STAssertTrue([dbCopy copyDatabaseFrom:source to:target withContent:YES], @"method renameDatabaseFrom:to: is supposed to return YES"); - - [mockConnection verify]; - [source release]; - [target release]; -} - -- (void) testCreateDatabase { - SPDatabaseCopy *dbCopy = [self getDatabaseCopyFixture]; - // test missing :) -} - -@end diff --git a/UnitTests/SPDatabaseInfoTest.h b/UnitTests/SPDatabaseInfoTest.h deleted file mode 100644 index 81763b4a..00000000 --- a/UnitTests/SPDatabaseInfoTest.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// $Id$ -// -// SPDatabaseInfoTest.h -// sequel-pro -// -// Created by David Rekowski -// Copyright (c) 2010 David Rekowski. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at <http://code.google.com/p/sequel-pro/> - -#define USE_APPLICATION_UNIT_TEST 1 - -#import <SenTestingKit/SenTestingKit.h> - - -@interface SPDatabaseInfoTest : SenTestCase { - -} - -- (void)testDatabaseExists; -- (void)testListDBs; -- (void)testListDBsLike; - - -@end diff --git a/UnitTests/SPDatabaseInfoTest.m b/UnitTests/SPDatabaseInfoTest.m deleted file mode 100644 index a53104e9..00000000 --- a/UnitTests/SPDatabaseInfoTest.m +++ /dev/null @@ -1,84 +0,0 @@ -// -// $Id$ -// -// SPDatabaseInfoTest.m -// sequel-pro -// -// Created by David Rekowski -// Copyright (c) 2010 David Rekowski. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at <http://code.google.com/p/sequel-pro/> - -#import <OCMock/OCMock.h> -#import "SPDatabaseInfo.h" -#import "SPDatabaseInfoTest.h" - - -@implementation SPDatabaseInfoTest - -- (SPDatabaseInfo *)getDatabaseInfoFixture { - SPDatabaseInfo *dbInfo = [[SPDatabaseInfo alloc] init]; - return dbInfo; -} - -- (id) getMockConnection { - id mockConnection = [OCMockObject niceMockForClass:[MCPConnection class]]; - return mockConnection; -} - -- (id) getMockMCPResult { - id mockResult = [OCMockObject niceMockForClass:[MCPResult class]]; - return mockResult; -} - -- (void)testDatabaseExists { - SPDatabaseInfo *dbInfo = [self getDatabaseInfoFixture]; - - NSArray *tables = [[NSArray alloc] initWithObjects: @"db_one", nil]; - id mockMCPResult = [self getMockMCPResult]; - [[mockMCPResult expect] numOfRows]; - [[[mockMCPResult stub] andReturn:[[NSNumber alloc] initWithInt:1]] numOfRows]; - [[mockMCPResult expect] fetchRowAsArray]; - [[[mockMCPResult stub] andReturn:tables] fetchRowAsArray]; - id mockConnection = [self getMockConnection]; - - [[[mockConnection expect] andReturn:mockMCPResult] queryString:@"SHOW DATABASES"]; - [dbInfo setConnection:mockConnection]; - [dbInfo databaseExists:@"db_one"]; - [mockConnection verify]; -} - -- (void)testListDBs { - SPDatabaseInfo *dbInfo = [self getDatabaseInfoFixture]; - id mockConnection = [self getMockConnection]; - [[mockConnection expect] queryString:@"SHOW DATABASES"]; - [dbInfo setConnection:mockConnection]; - [dbInfo listDBs]; - [mockConnection verify]; -} - -- (void)testListDBsLike { - SPDatabaseInfo *dbInfo = [self getDatabaseInfoFixture]; - id mockConnection = [self getMockConnection]; - [[mockConnection expect] queryString:@"SHOW DATABASES LIKE `test_db`"]; - [dbInfo setConnection:mockConnection]; - [dbInfo listDBsLike:@"test_db"]; - [mockConnection verify]; -} - - -@end diff --git a/UnitTests/SPDatabaseRenameTest.h b/UnitTests/SPDatabaseRenameTest.h deleted file mode 100644 index 473f4716..00000000 --- a/UnitTests/SPDatabaseRenameTest.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// $Id$ -// -// SPDatabaseRenameTest.h -// sequel-pro -// -// Created by David Rekowski -// Copyright (c) 2010 David Rekowski. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at <http://code.google.com/p/sequel-pro/> - -#define USE_APPLICATION_UNIT_TEST 1 - -#import <SenTestingKit/SenTestingKit.h> - -@interface SPDatabaseRenameTest : SenTestCase { -} -- (void) testRenameDatabase; -- (void) testCreateDatabase; - -@end diff --git a/UnitTests/SPDatabaseRenameTest.m b/UnitTests/SPDatabaseRenameTest.m deleted file mode 100644 index 51562db9..00000000 --- a/UnitTests/SPDatabaseRenameTest.m +++ /dev/null @@ -1,91 +0,0 @@ -// -// $Id$ -// -// SPDatabaseRenameTest.m -// sequel-pro -// -// Created by David Rekowski -// Copyright (c) 2010 David Rekowski. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// 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 "SPStringAdditions.h" -#import "SPLogger.h" - - -@implementation SPDatabaseRenameTest - -- (SPDatabaseRename *) getDatabaseRenameFixture { - SPDatabaseRename *dbRename = [[SPDatabaseRename alloc] init]; - return [dbRename autorelease]; -} - -- (SPTableCopy *) getTableCopyFixture { - SPTableCopy *tableCopy = [[SPTableCopy alloc] init]; - return [tableCopy autorelease]; -} - -- (id) getMockConnection { - id mockConnection = [OCMockObject niceMockForClass:[MCPConnection class]]; - return mockConnection; -} - -- (id) getMockDBInfo { - id mockDBInfo = [OCMockObject niceMockForClass:[SPDatabaseInfo class]]; - return mockDBInfo; -} - -- (void) testRenameDatabase { - - SPDatabaseRename *dbRename = [self getDatabaseRenameFixture]; - - id mockConnection = [self getMockConnection]; - [[mockConnection expect] queryString:@"CREATE DATABASE `target_name`"]; - [[mockConnection expect] listTablesFromDB:@"source_name"]; - [[[mockConnection stub] andReturn:[[NSArray alloc] init]] listTablesFromDB:@"source_name"]; - [dbRename setConnection:mockConnection]; - - id mockDBInfo = [self getMockDBInfo]; - - BOOL varNo = NO; - BOOL varYes = YES; - [[[mockDBInfo expect] andReturnValue:[NSValue value:&varYes withObjCType:@encode(BOOL)]] databaseExists:@"source_name"]; - - [[[mockDBInfo expect] andReturnValue:[NSValue value:&varNo withObjCType:@encode(BOOL)]] databaseExists:@"target_name"]; - - [dbRename setDbInfo:mockDBInfo]; - - NSString *source = [[NSString alloc] initWithString:@"source_name"]; - NSString *target = [[NSString alloc] initWithString:@"target_name"]; - STAssertTrue([dbRename renameDatabaseFrom:source to:target], @"method renameDatabaseFrom:to: is supposed to return YES"); - - [mockConnection verify]; - [source release]; - [target release]; -} - -- (void) testCreateDatabase { - SPDatabaseRename *dbRename = [self getDatabaseRenameFixture]; -} - -@end diff --git a/UnitTests/SPTableCopyTest.h b/UnitTests/SPTableCopyTest.h deleted file mode 100644 index 25d0da7b..00000000 --- a/UnitTests/SPTableCopyTest.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// $Id$ -// -// SPTableCopyTest.h -// sequel-pro -// -// Created by David Rekowski -// Copyright (c) 2010 David Rekowski. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at <http://code.google.com/p/sequel-pro/> - -#define USE_APPLICATION_UNIT_TEST 1 - -#import <SenTestingKit/SenTestingKit.h> - -@interface SPTableCopyTest : SenTestCase { - -} - -- (void)testCopyTableFromToWithData; - - -@end diff --git a/UnitTests/SPTableCopyTest.m b/UnitTests/SPTableCopyTest.m deleted file mode 100644 index f0e31c14..00000000 --- a/UnitTests/SPTableCopyTest.m +++ /dev/null @@ -1,72 +0,0 @@ -// -// $Id$ -// -// SPTableCopyTest.m -// sequel-pro -// -// Created by David Rekowski -// Copyright (c) 2010 David Rekowski. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at <http://code.google.com/p/sequel-pro/> - -#import <OCMock/OCMock.h> -#import "SPTableCopy.h" -#import "SPTableCopyTest.h" - - -@implementation SPTableCopyTest - -- (id) getMockConnection { - id mockConnection = [OCMockObject niceMockForClass:[MCPConnection class]]; - return [mockConnection autorelease]; -} - -- (id) getMockResult { - id mockResult = [OCMockObject niceMockForClass:[MCPResult class]]; - return mockResult; -} - -- (SPTableCopy *) getTableCopyFixture { - SPTableCopy *tableCopy = [[SPTableCopy alloc] init]; - return [tableCopy autorelease]; -} - -- (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]; - - 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]; - [mockResult verify]; - [mockConnection verify]; - [resultArray release]; -} - -@end |