@@ -3,28 +3,25 @@ import SQLite
33
44class ConnectionPoolTests : SQLiteTestCase {
55
6+ var pool : ConnectionPool !
7+
68 override func setUp( ) {
7- super. setUp ( )
9+ let _ = try ? NSFileManager . defaultManager ( ) . removeItemAtPath ( " \( NSTemporaryDirectory ( ) ) /SQLite.swift Pool Tests.sqlite " )
10+ pool = try ! ConnectionPool ( . URI( " \( NSTemporaryDirectory ( ) ) /SQLite.swift Pool Tests.sqlite " ) )
811 }
912
1013 func testConnectionSetupClosures( ) {
1114
12- let _ = try ? NSFileManager . defaultManager ( ) . removeItemAtPath ( " \( NSTemporaryDirectory ( ) ) /SQLite.swift Pool Tests.sqlite " )
13- let pool = try ! ConnectionPool ( . URI( " \( NSTemporaryDirectory ( ) ) /SQLite.swift Pool Tests.sqlite " ) )
14-
1515 pool. foreignKeys = true
1616 pool. setup. append { try $0. execute ( " CREATE TABLE IF NOT EXISTS test(value INT) " ) }
1717
18- XCTAssertTrue ( try pool. readable. scalar ( " PRAGMA foreign_keys " ) as! Int64 == 1 )
18+ XCTAssertTrue ( pool. readable. scalar ( " PRAGMA foreign_keys " ) as! Int64 == 1 )
1919 try ! pool. writable. execute ( " INSERT INTO test(value) VALUES (1) " )
2020 try ! pool. readable. execute ( " SELECT value FROM test " )
2121 }
2222
2323 func testConcurrentAccess2( ) {
2424
25- let _ = try ? NSFileManager . defaultManager ( ) . removeItemAtPath ( " \( NSTemporaryDirectory ( ) ) /SQLite.swift Pool Tests.sqlite " )
26- let pool = try ! ConnectionPool ( . URI( " \( NSTemporaryDirectory ( ) ) /SQLite.swift Pool Tests.sqlite " ) )
27-
2825 let conn = pool. writable
2926 try ! conn. execute ( " DROP TABLE IF EXISTS test; CREATE TABLE test(id INTEGER PRIMARY KEY, name TEXT); " )
3027 try ! conn. execute ( " DELETE FROM test " )
@@ -45,7 +42,7 @@ class ConnectionPoolTests : SQLiteTestCase {
4542
4643 print ( " started " , x)
4744
48- let conn = pool. readable
45+ let conn = self . pool. readable
4946
5047 let stmt = try ! conn. prepare ( " SELECT name FROM test WHERE id = ? " )
5148 var curr = stmt. scalar ( x) as! String
@@ -87,9 +84,6 @@ class ConnectionPoolTests : SQLiteTestCase {
8784
8885 func testConcurrentAccess( ) throws {
8986
90- let _ = try ? NSFileManager . defaultManager ( ) . removeItemAtPath ( " \( NSTemporaryDirectory ( ) ) /SQLite.swift Pool Tests.sqlite " )
91- let pool = try ! ConnectionPool ( . URI( " \( NSTemporaryDirectory ( ) ) /SQLite.swift Pool Tests.sqlite " ) )
92-
9387 try ! pool. writable. execute ( " DROP TABLE IF EXISTS test; CREATE TABLE test(value); " )
9488 try ! pool. writable. run ( " INSERT INTO test(value) VALUES(?) " , 0 )
9589
@@ -102,7 +96,7 @@ class ConnectionPoolTests : SQLiteTestCase {
10296
10397 while !finished {
10498
105- let val = pool. readable. scalar ( " SELECT value FROM test " )
99+ let val = self . pool. readable. scalar ( " SELECT value FROM test " )
106100 assert ( val != nil , " DB query returned nil result set " )
107101
108102 }
@@ -129,9 +123,6 @@ class ConnectionPoolTests : SQLiteTestCase {
129123
130124 func testAutoRelease( ) {
131125
132- let _ = try ? NSFileManager . defaultManager ( ) . removeItemAtPath ( " \( NSTemporaryDirectory ( ) ) /SQLite.swift Pool Tests.sqlite " )
133- let pool = try ! ConnectionPool ( . URI( " \( NSTemporaryDirectory ( ) ) /SQLite.swift Pool Tests.sqlite " ) )
134-
135126 do {
136127 try ! pool. readable. execute ( " SELECT 1 " )
137128 }
0 commit comments