From bc244802c0508e228e668c866384c56bd806f321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 12 Apr 2018 07:58:23 +0200 Subject: [PATCH] Update tests for DatabasePool/Writer.writeWithoutTransaction --- .../DatabasePoolConcurrencyTests.swift | 26 +++++++++---------- .../DatabasePoolSchemaCacheTests.swift | 2 +- Tests/GRDBTests/DatabaseSnapshotTests.swift | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Tests/GRDBTests/DatabasePoolConcurrencyTests.swift b/Tests/GRDBTests/DatabasePoolConcurrencyTests.swift index 6cfaf1850..4b99cdc7b 100644 --- a/Tests/GRDBTests/DatabasePoolConcurrencyTests.swift +++ b/Tests/GRDBTests/DatabasePoolConcurrencyTests.swift @@ -256,7 +256,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { // dbPool.read // throws let block1 = { () in - try! dbPool.write { db in + try! dbPool.writeWithoutTransaction { db in try db.execute("PRAGMA locking_mode=EXCLUSIVE") try db.execute("CREATE TABLE items (id INTEGER PRIMARY KEY)") s1.signal() @@ -369,7 +369,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { do { _ = s1.wait(timeout: .distantFuture) defer { s2.signal() } - try dbPool.write { db in + try dbPool.writeWithoutTransaction { db in try db.execute("DELETE FROM items") } } catch { @@ -419,7 +419,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { do { _ = s1.wait(timeout: .distantFuture) defer { s2.signal() } - try dbPool.write { db in + try dbPool.writeWithoutTransaction { db in try db.execute("DELETE FROM items") } try dbPool.checkpoint() @@ -468,7 +468,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { let block2 = { () in do { _ = s1.wait(timeout: .distantFuture) - try dbPool.write { db in + try dbPool.writeWithoutTransaction { db in try db.execute("INSERT INTO items (id) VALUES (NULL)") s2.signal() _ = s3.wait(timeout: .distantFuture) @@ -515,7 +515,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { do { _ = s1.wait(timeout: .distantFuture) defer { s2.signal() } - try dbPool.write { db in + try dbPool.writeWithoutTransaction { db in try db.execute("INSERT INTO items (id) VALUES (NULL)") } try dbPool.checkpoint() @@ -556,7 +556,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { let block1 = { () in do { - try dbPool.write { db in + try dbPool.writeWithoutTransaction { db in try db.execute("INSERT INTO items (id) VALUES (NULL)") s1.signal() _ = s2.wait(timeout: .distantFuture) @@ -686,7 +686,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { do { _ = s1.wait(timeout: .distantFuture) defer { s2.signal() } - try dbPool.write { db in + try dbPool.writeWithoutTransaction { db in try db.execute("DELETE FROM items") } } catch { @@ -736,7 +736,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { do { _ = s1.wait(timeout: .distantFuture) defer { s2.signal() } - try dbPool.write { db in + try dbPool.writeWithoutTransaction { db in try db.execute("DELETE FROM items") } try dbPool.checkpoint() @@ -780,7 +780,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { do { _ = s1.wait(timeout: .distantFuture) defer { s2.signal() } - try dbPool.write { db in + try dbPool.writeWithoutTransaction { db in try db.execute("INSERT INTO items (id) VALUES (NULL)") } try dbPool.checkpoint() @@ -797,7 +797,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { func testReadFromCurrentStateOpensATransaction() throws { let dbPool = try makeDatabasePool() let s = DispatchSemaphore(value: 0) - try dbPool.write { db in + try dbPool.writeWithoutTransaction { db in try dbPool.readFromCurrentState { db in XCTAssertTrue(db.isInsideTransaction) do { @@ -820,7 +820,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { } // Writer Reader - // dbPool.write { + // dbPool.writeWithoutTransaction { // > // dbPool.readFromCurrentState { // < @@ -833,7 +833,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { // } var i: Int! = nil - try dbPool.write { db in + try dbPool.writeWithoutTransaction { db in try dbPool.readFromCurrentState { db in _ = s1.wait(timeout: .distantFuture) i = try! Int.fetchOne(db, "SELECT COUNT(*) FROM persons")! @@ -849,7 +849,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { func testReadFromCurrentStateError() throws { dbConfiguration.trace = { print($0) } let dbPool = try makeDatabasePool() - try dbPool.write { db in + try dbPool.writeWithoutTransaction { db in try db.execute("PRAGMA locking_mode=EXCLUSIVE") try db.execute("CREATE TABLE items (id INTEGER PRIMARY KEY)") do { diff --git a/Tests/GRDBTests/DatabasePoolSchemaCacheTests.swift b/Tests/GRDBTests/DatabasePoolSchemaCacheTests.swift index ba61cdd02..677cefe89 100644 --- a/Tests/GRDBTests/DatabasePoolSchemaCacheTests.swift +++ b/Tests/GRDBTests/DatabasePoolSchemaCacheTests.swift @@ -148,7 +148,7 @@ class DatabasePoolSchemaCacheTests : GRDBTestCase { // table exists: false let block1 = { () in - try! dbPool.write { db in + try! dbPool.writeWithoutTransaction { db in try db.execute("CREATE TABLE foo(id INTEGER PRIMARY KEY)") // warm cache _ = try db.primaryKey("foo") diff --git a/Tests/GRDBTests/DatabaseSnapshotTests.swift b/Tests/GRDBTests/DatabaseSnapshotTests.swift index e988626f9..a6fe799e9 100644 --- a/Tests/GRDBTests/DatabaseSnapshotTests.swift +++ b/Tests/GRDBTests/DatabaseSnapshotTests.swift @@ -25,7 +25,7 @@ class DatabaseSnapshotTests: GRDBTestCase { func testSnapshotSeesLatestTransaction() throws { let dbPool = try makeDatabasePool() - try dbPool.write { db in + try dbPool.writeWithoutTransaction { db in try db.create(table: "t") { $0.column("id", .integer).primaryKey() } try db.execute("INSERT INTO t DEFAULT VALUES") let snapshot = try dbPool.makeSnapshot()