mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
ValueObservation.print() tweaks
This commit is contained in:
1 parent
115f293e26
commit
3a4ab7a6aa
2 files changed
+81
-81
No files matched your search
@@ -172,13 +172,13 @@ extension ValueObservation: Refinable {
|
||||
let prefix = prefix.isEmpty ? "" : "\(prefix): "
|
||||
var stream = stream ?? PrintOutputStream()
|
||||
return handleEvents(
|
||||
willStart: { stream.write("\(prefix)will start") },
|
||||
willFetch: { stream.write("\(prefix)will fetch") },
|
||||
willTrackRegion: { stream.write("\(prefix)will track region: \($0)") },
|
||||
willStart: { stream.write("\(prefix)start") },
|
||||
willFetch: { stream.write("\(prefix)fetch") },
|
||||
willTrackRegion: { stream.write("\(prefix)tracked region: \($0)") },
|
||||
databaseDidChange: { stream.write("\(prefix)database did change") },
|
||||
didReceiveValue: { stream.write("\(prefix)did receive value: \($0)") },
|
||||
didFail: { stream.write("\(prefix)did fail: \($0)") },
|
||||
didCancel: { stream.write("\(prefix)did cancel") })
|
||||
didReceiveValue: { stream.write("\(prefix)value: \($0)") },
|
||||
didFail: { stream.write("\(prefix)failure: \($0)") },
|
||||
didCancel: { stream.write("\(prefix)cancel") })
|
||||
}
|
||||
|
||||
// MARK: - Fetching Values
|
||||
|
||||
@@ -43,9 +43,9 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger.strings, [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did receive value: nil"])
|
||||
"start",
|
||||
"fetch",
|
||||
"value: nil"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,9 +77,9 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger.strings, [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did receive value: nil"])
|
||||
"start",
|
||||
"fetch",
|
||||
"value: nil"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,9 +109,9 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger.strings, [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did fail: TestError()"])
|
||||
"start",
|
||||
"fetch",
|
||||
"failure: TestError()"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,9 +141,9 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger.strings, [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did fail: TestError()"])
|
||||
"start",
|
||||
"fetch",
|
||||
"failure: TestError()"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,13 +184,13 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger.strings.prefix(7), [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did receive value: nil",
|
||||
"will track region: \(expectedRegion)",
|
||||
"start",
|
||||
"fetch",
|
||||
"value: nil",
|
||||
"tracked region: \(expectedRegion)",
|
||||
"database did change",
|
||||
"will fetch",
|
||||
"did receive value: Optional(1)"])
|
||||
"fetch",
|
||||
"value: Optional(1)"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,13 +226,13 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger.strings.prefix(7), [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did receive value: nil",
|
||||
"will track region: \(expectedRegion)",
|
||||
"start",
|
||||
"fetch",
|
||||
"value: nil",
|
||||
"tracked region: \(expectedRegion)",
|
||||
"database did change",
|
||||
"will fetch",
|
||||
"did receive value: Optional(1)"])
|
||||
"fetch",
|
||||
"value: Optional(1)"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,9 +257,9 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger.strings, [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did fail: SQLite error 1 with statement `SELECT MAX(id) FROM player`: no such table: player"])
|
||||
"start",
|
||||
"fetch",
|
||||
"failure: SQLite error 1 with statement `SELECT MAX(id) FROM player`: no such table: player"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,9 +284,9 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger.strings, [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did fail: SQLite error 1 with statement `SELECT MAX(id) FROM player`: no such table: player"])
|
||||
"start",
|
||||
"fetch",
|
||||
"failure: SQLite error 1 with statement `SELECT MAX(id) FROM player`: no such table: player"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,13 +323,13 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger.strings, [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did receive value: nil",
|
||||
"will track region: \(expectedRegion)",
|
||||
"start",
|
||||
"fetch",
|
||||
"value: nil",
|
||||
"tracked region: \(expectedRegion)",
|
||||
"database did change",
|
||||
"will fetch",
|
||||
"did fail: SQLite error 1 with statement `SELECT MAX(id) FROM player`: no such table: player"])
|
||||
"fetch",
|
||||
"failure: SQLite error 1 with statement `SELECT MAX(id) FROM player`: no such table: player"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,13 +366,13 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger.strings, [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did receive value: nil",
|
||||
"will track region: \(expectedRegion)",
|
||||
"start",
|
||||
"fetch",
|
||||
"value: nil",
|
||||
"tracked region: \(expectedRegion)",
|
||||
"database did change",
|
||||
"will fetch",
|
||||
"did fail: SQLite error 1 with statement `SELECT MAX(id) FROM player`: no such table: player"])
|
||||
"fetch",
|
||||
"failure: SQLite error 1 with statement `SELECT MAX(id) FROM player`: no such table: player"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,13 +419,13 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger.strings, [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did receive value: nil",
|
||||
"will track region: \(expectedRegion)",
|
||||
"start",
|
||||
"fetch",
|
||||
"value: nil",
|
||||
"tracked region: \(expectedRegion)",
|
||||
"database did change",
|
||||
"will fetch",
|
||||
"did receive value: nil"])
|
||||
"fetch",
|
||||
"value: nil"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,13 +466,13 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger.strings, [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did receive value: nil",
|
||||
"will track region: \(expectedRegion)",
|
||||
"start",
|
||||
"fetch",
|
||||
"value: nil",
|
||||
"tracked region: \(expectedRegion)",
|
||||
"database did change",
|
||||
"will fetch",
|
||||
"did receive value: nil"])
|
||||
"fetch",
|
||||
"value: nil"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,17 +518,17 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger.strings.prefix(11), [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did receive value: nil",
|
||||
"will track region: \(expectedRegionA),choice(t)",
|
||||
"start",
|
||||
"fetch",
|
||||
"value: nil",
|
||||
"tracked region: \(expectedRegionA),choice(t)",
|
||||
"database did change",
|
||||
"will fetch",
|
||||
"will track region: \(expectedRegionB),choice(t)",
|
||||
"did receive value: Optional(1)",
|
||||
"fetch",
|
||||
"tracked region: \(expectedRegionB),choice(t)",
|
||||
"value: Optional(1)",
|
||||
"database did change",
|
||||
"will fetch",
|
||||
"did receive value: Optional(2)"])
|
||||
"fetch",
|
||||
"value: Optional(2)"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -556,13 +556,13 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger1.strings.prefix(3), [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did receive value: nil"])
|
||||
"start",
|
||||
"fetch",
|
||||
"value: nil"])
|
||||
XCTAssertEqual(logger2.strings.prefix(3), [
|
||||
"log: will start",
|
||||
"log: will fetch",
|
||||
"log: did receive value: nil"])
|
||||
"log: start",
|
||||
"log: fetch",
|
||||
"log: value: nil"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,13 +590,13 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(logger1.strings.prefix(3), [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did receive value: nil"])
|
||||
"start",
|
||||
"fetch",
|
||||
"value: nil"])
|
||||
XCTAssertEqual(logger2.strings.prefix(3), [
|
||||
"will start",
|
||||
"will fetch",
|
||||
"did receive value: foo"])
|
||||
"start",
|
||||
"fetch",
|
||||
"value: foo"])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user