mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
Tests for DatabaseQueue.execute() and DatabasePool.execute()
This commit is contained in:
1 parent
eecaa2a394
commit
c8afca6485
3 files changed
+50
-15
No files matched your search
@@ -103,6 +103,8 @@
|
||||
563363B81C933FF8000BE133 /* DatabaseQueueMutablePersistableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563363AD1C933FF8000BE133 /* DatabaseQueueMutablePersistableTests.swift */; };
|
||||
563363B91C933FF8000BE133 /* DatabaseQueuePersistableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563363AE1C933FF8000BE133 /* DatabaseQueuePersistableTests.swift */; };
|
||||
563363BA1C933FF8000BE133 /* DatabaseQueuePersistableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563363AE1C933FF8000BE133 /* DatabaseQueuePersistableTests.swift */; };
|
||||
563363BD1C93FD5E000BE133 /* DatabaseQueueConcurrencyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563363BC1C93FD5E000BE133 /* DatabaseQueueConcurrencyTests.swift */; };
|
||||
563363BE1C93FD5E000BE133 /* DatabaseQueueConcurrencyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563363BC1C93FD5E000BE133 /* DatabaseQueueConcurrencyTests.swift */; };
|
||||
563445051C4A7FD7003D3DC6 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563445041C4A7FD7003D3DC6 /* Utils.swift */; };
|
||||
563445061C4A7FD7003D3DC6 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563445041C4A7FD7003D3DC6 /* Utils.swift */; };
|
||||
564A50C71BFF4B7F00B3A3A2 /* CollationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564A50C61BFF4B7F00B3A3A2 /* CollationTests.swift */; };
|
||||
@@ -207,8 +209,6 @@
|
||||
56A238B71B9CA2590082EB20 /* DatabaseTimestampTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238B51B9CA2590082EB20 /* DatabaseTimestampTests.swift */; };
|
||||
56A5E4091BA2BCF900707640 /* RecordWithColumnNameManglingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A5E4081BA2BCF900707640 /* RecordWithColumnNameManglingTests.swift */; };
|
||||
56A5E40A1BA2BCF900707640 /* RecordWithColumnNameManglingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A5E4081BA2BCF900707640 /* RecordWithColumnNameManglingTests.swift */; };
|
||||
56AC8CCE1BA3F2AD009E4319 /* ConcurrencyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56AC8CCD1BA3F2AD009E4319 /* ConcurrencyTests.swift */; };
|
||||
56AC8CCF1BA3F2AD009E4319 /* ConcurrencyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56AC8CCD1BA3F2AD009E4319 /* ConcurrencyTests.swift */; };
|
||||
56B7F42A1BE14A1900E39BBF /* CGFloatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */; };
|
||||
56B7F42F1BE14CD700E39BBF /* CGFloatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */; };
|
||||
56B7F4371BE4C11200E39BBF /* DatabaseCoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4361BE4C11200E39BBF /* DatabaseCoderTests.swift */; };
|
||||
@@ -380,6 +380,7 @@
|
||||
563363AC1C933FF8000BE133 /* DatabasePoolPersistableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabasePoolPersistableTests.swift; sourceTree = "<group>"; };
|
||||
563363AD1C933FF8000BE133 /* DatabaseQueueMutablePersistableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseQueueMutablePersistableTests.swift; sourceTree = "<group>"; };
|
||||
563363AE1C933FF8000BE133 /* DatabaseQueuePersistableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseQueuePersistableTests.swift; sourceTree = "<group>"; };
|
||||
563363BC1C93FD5E000BE133 /* DatabaseQueueConcurrencyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseQueueConcurrencyTests.swift; sourceTree = "<group>"; };
|
||||
563445041C4A7FD7003D3DC6 /* Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
|
||||
564A50C61BFF4B7F00B3A3A2 /* CollationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollationTests.swift; sourceTree = "<group>"; };
|
||||
56553C181C3E906C00522B5C /* GRDBOSXCrashTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBOSXCrashTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@@ -436,7 +437,6 @@
|
||||
56A238A11B9C753B0082EB20 /* Record.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Record.swift; sourceTree = "<group>"; };
|
||||
56A238B51B9CA2590082EB20 /* DatabaseTimestampTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseTimestampTests.swift; sourceTree = "<group>"; };
|
||||
56A5E4081BA2BCF900707640 /* RecordWithColumnNameManglingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecordWithColumnNameManglingTests.swift; sourceTree = "<group>"; };
|
||||
56AC8CCD1BA3F2AD009E4319 /* ConcurrencyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConcurrencyTests.swift; sourceTree = "<group>"; };
|
||||
56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGFloatTests.swift; sourceTree = "<group>"; };
|
||||
56B7F4361BE4C11200E39BBF /* DatabaseCoderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseCoderTests.swift; sourceTree = "<group>"; };
|
||||
56B7F4391BEB42D500E39BBF /* Migration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Migration.swift; sourceTree = "<group>"; };
|
||||
@@ -672,6 +672,14 @@
|
||||
path = FetchRequest;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
563363BB1C93FD32000BE133 /* DatabaseQueue */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
563363BC1C93FD5E000BE133 /* DatabaseQueueConcurrencyTests.swift */,
|
||||
);
|
||||
path = DatabaseQueue;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
564A50BF1BFF4B6E00B3A3A2 /* Collation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -724,10 +732,10 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
564A50BF1BFF4B6E00B3A3A2 /* Collation */,
|
||||
56AC8CCC1BA3F267009E4319 /* Concurrency */,
|
||||
56A238121B9C74A90082EB20 /* Database */,
|
||||
56A238151B9C74A90082EB20 /* DatabaseError */,
|
||||
560A37A91C90084600949E71 /* DatabasePool */,
|
||||
563363BB1C93FD32000BE133 /* DatabaseQueue */,
|
||||
560B3FA41C19DFF800C58EC7 /* Persistable */,
|
||||
56EA86921C91DFDA002BB4DF /* DatabaseReader */,
|
||||
56A238171B9C74A90082EB20 /* DatabaseValue */,
|
||||
@@ -878,14 +886,6 @@
|
||||
path = Record;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
56AC8CCC1BA3F267009E4319 /* Concurrency */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56AC8CCD1BA3F2AD009E4319 /* ConcurrencyTests.swift */,
|
||||
);
|
||||
path = Concurrency;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
56B7F4281BE149F600E39BBF /* CoreGraphics */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -1431,8 +1431,8 @@
|
||||
56A238601B9C74A90082EB20 /* RecordDescriptionTests.swift in Sources */,
|
||||
56300B861C54DC95005A543B /* Record+FetchRequestTests.swift in Sources */,
|
||||
56A238561B9C74A90082EB20 /* PrimaryKeyNoneTests.swift in Sources */,
|
||||
563363BE1C93FD5E000BE133 /* DatabaseQueueConcurrencyTests.swift in Sources */,
|
||||
56A238501B9C74A90082EB20 /* MinimalPrimaryKeyRowIDTests.swift in Sources */,
|
||||
56AC8CCF1BA3F2AD009E4319 /* ConcurrencyTests.swift in Sources */,
|
||||
56A238461B9C74A90082EB20 /* DictionaryRowTests.swift in Sources */,
|
||||
56B7F4381BE4C11200E39BBF /* DatabaseCoderTests.swift in Sources */,
|
||||
564A50C81BFF4B7F00B3A3A2 /* CollationTests.swift in Sources */,
|
||||
@@ -1506,9 +1506,9 @@
|
||||
5614DEF81BAA1B43003163B3 /* DatabaseValueConversionTests.swift in Sources */,
|
||||
56300B851C54DC95005A543B /* Record+FetchRequestTests.swift in Sources */,
|
||||
56A2385F1B9C74A90082EB20 /* RecordDescriptionTests.swift in Sources */,
|
||||
563363BD1C93FD5E000BE133 /* DatabaseQueueConcurrencyTests.swift in Sources */,
|
||||
56A238551B9C74A90082EB20 /* PrimaryKeyNoneTests.swift in Sources */,
|
||||
56A2384F1B9C74A90082EB20 /* MinimalPrimaryKeyRowIDTests.swift in Sources */,
|
||||
56AC8CCE1BA3F2AD009E4319 /* ConcurrencyTests.swift in Sources */,
|
||||
56A238451B9C74A90082EB20 /* DictionaryRowTests.swift in Sources */,
|
||||
56A238491B9C74A90082EB20 /* SelectStatementTests.swift in Sources */,
|
||||
56B7F4371BE4C11200E39BBF /* DatabaseCoderTests.swift in Sources */,
|
||||
|
||||
@@ -3,7 +3,16 @@ import GRDB
|
||||
|
||||
class DatabasePoolConcurrencyTests: GRDBTestCase {
|
||||
|
||||
func testBasicWriteRead() {
|
||||
func testUnwrappedReadWrite() {
|
||||
assertNoError {
|
||||
try dbPool.execute("CREATE TABLE items (id INTEGER PRIMARY KEY)")
|
||||
try dbPool.execute("INSERT INTO items (id) VALUES (NULL)")
|
||||
let id = Int.fetchOne(dbPool, "SELECT id FROM items")!
|
||||
XCTAssertEqual(id, 1)
|
||||
}
|
||||
}
|
||||
|
||||
func testWrappedReadWrite() {
|
||||
assertNoError {
|
||||
try dbPool.write { db in
|
||||
try db.execute("CREATE TABLE items (id INTEGER PRIMARY KEY)")
|
||||
|
||||
+26
@@ -53,6 +53,32 @@ class ConcurrencyTests: XCTestCase {
|
||||
dbQueue2 = nil
|
||||
try! NSFileManager.defaultManager().removeItemAtPath(databasePath)
|
||||
}
|
||||
|
||||
func testUnwrappedReadWrite() {
|
||||
do {
|
||||
try dbQueue1.execute("CREATE TABLE items (id INTEGER PRIMARY KEY)")
|
||||
try dbQueue1.execute("INSERT INTO items (id) VALUES (NULL)")
|
||||
let id = Int.fetchOne(dbQueue1, "SELECT id FROM items")!
|
||||
XCTAssertEqual(id, 1)
|
||||
} catch {
|
||||
XCTFail("error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func testWrappedReadWrite() {
|
||||
do {
|
||||
try dbQueue1.inDatabase { db in
|
||||
try db.execute("CREATE TABLE items (id INTEGER PRIMARY KEY)")
|
||||
try db.execute("INSERT INTO items (id) VALUES (NULL)")
|
||||
}
|
||||
let id = dbQueue1.inDatabase { db in
|
||||
Int.fetchOne(db, "SELECT id FROM items")!
|
||||
}
|
||||
XCTAssertEqual(id, 1)
|
||||
} catch {
|
||||
XCTFail("error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func testDeferredTransactionConcurrency() {
|
||||
// Queue 1 Queue 2
|
||||
Reference in new issue
Block a user