aboutsummaryrefslogtreecommitdiffstats
path: root/UnitTests/SPDatabaseInfoTest.m
diff options
context:
space:
mode:
authordrx777 <david.rekowski@gmx.de>2010-04-28 17:11:41 +0000
committerdrx777 <david.rekowski@gmx.de>2010-04-28 17:11:41 +0000
commitf36685ae1bee7b9274de27414ab8b64dbc57770f (patch)
tree269b242812332fab9bfdbe37955fbfbe72a87def /UnitTests/SPDatabaseInfoTest.m
parent29b42d1c3b751781fb70684f5bb779001d19b1f3 (diff)
downloadsequelpro-f36685ae1bee7b9274de27414ab8b64dbc57770f.tar.gz
sequelpro-f36685ae1bee7b9274de27414ab8b64dbc57770f.tar.bz2
sequelpro-f36685ae1bee7b9274de27414ab8b64dbc57770f.zip
This changeset implements renaming and duplicating databases on a server. Details as follows:
* altered MCPConnection listTablesFromDB:like: to return NSArray * altered MCPConnection listFieldsFromTable:like: to use backtick quoted strings for table and fieldnames * added MCPConnection listTablesFromDB for a complete table list * added SPStringAdditions.h to various files to prevent warnings * added sheets for duplicate/rename DB in DBView.xib * added duplicate/rename menu items to MainMenu.xib * added outlets in TableDocument: databaseNewSheet databaseRenameSheet databaseCopyNameField databaseRenameNameField copyOnlyStructureButton copyDatabaseButton renameDatabaseButton * added methods in TableDocument: getConnection, copyDatabase, renameDatabase, _copyDatabase, _renameDatabase * added OCMock Framework for object mocking in tests * added group Others/DatabaseActions
Diffstat (limited to 'UnitTests/SPDatabaseInfoTest.m')
-rw-r--r--UnitTests/SPDatabaseInfoTest.m67
1 files changed, 67 insertions, 0 deletions
diff --git a/UnitTests/SPDatabaseInfoTest.m b/UnitTests/SPDatabaseInfoTest.m
new file mode 100644
index 00000000..0e813350
--- /dev/null
+++ b/UnitTests/SPDatabaseInfoTest.m
@@ -0,0 +1,67 @@
+//
+// SPDatabaseInfoTest.m
+// sequel-pro
+//
+// Created by David Rekowski on 22.04.10.
+// Copyright 2010 Papaya Software GmbH. All rights reserved.
+//
+
+#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