diff options
author | stuconnolly <stuart02@gmail.com> | 2012-05-04 14:59:19 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2012-05-04 14:59:19 +0000 |
commit | f5710a1bb906bd9c8220fba162ebf29fa986aaa5 (patch) | |
tree | 9a23295ec8f489864cce6eaa187b3e945832986c /UnitTests/SPTableCopyTest.m | |
parent | e188d1d53a1b1f8cf96d8ce82221f2013e63c23b (diff) | |
download | sequelpro-f5710a1bb906bd9c8220fba162ebf29fa986aaa5.tar.gz sequelpro-f5710a1bb906bd9c8220fba162ebf29fa986aaa5.tar.bz2 sequelpro-f5710a1bb906bd9c8220fba162ebf29fa986aaa5.zip |
Tidy up database action tests.
Diffstat (limited to 'UnitTests/SPTableCopyTest.m')
-rw-r--r-- | UnitTests/SPTableCopyTest.m | 35 |
1 files changed, 21 insertions, 14 deletions
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]; |