forked from ccgus/fmdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFMDBTempDBTests.m
63 lines (47 loc) · 1.4 KB
/
FMDBTempDBTests.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// FMDBTempDBTests.m
// fmdb
//
// Created by Graham Dennis on 24/11/2013.
//
//
#import "FMDBTempDBTests.h"
static NSString *const testDatabasePath = @"/tmp/tmp.db";
static NSString *const populatedDatabasePath = @"/tmp/tmp-populated.db";
@implementation FMDBTempDBTests
+ (void)setUp
{
[super setUp];
// Delete old populated database
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtPath:populatedDatabasePath error:NULL];
if ([self respondsToSelector:@selector(populateDatabase:)]) {
FMDatabase *db = [FMDatabase databaseWithPath:populatedDatabasePath];
[db open];
[self populateDatabase:db];
[db close];
}
}
- (void)setUp
{
[super setUp];
// Delete the old database
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtPath:testDatabasePath error:NULL];
if ([[self class] respondsToSelector:@selector(populateDatabase:)]) {
[fileManager copyItemAtPath:populatedDatabasePath toPath:testDatabasePath error:NULL];
}
self.db = [FMDatabase databaseWithPath:testDatabasePath];
XCTAssertTrue([self.db open], @"Wasn't able to open database");
[self.db setShouldCacheStatements:YES];
}
- (void)tearDown
{
[super tearDown];
[self.db close];
}
- (NSString *)databasePath
{
return testDatabasePath;
}
@end