groue/grdbsnapshottesting
**The snapshot testing library for GRDB**
Usage
import GRDB
import GRDBSnapshotTesting
import InlineSnapshotTesting
import XCTest
class MyDatabaseTests: XCTestCase {
func test_full_database_content() throws {
let dbQueue = try makeMyDatabase()
assertInlineSnapshot(of: dbQueue, as: .dumpContent()) {
"""
sqlite_master
CREATE TABLE player (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
score INTEGER NOT NULL);
player
- id: 1
name: 'Arthur'
score: 500
- id: 2
name: 'Barbara'
score: 1000
"""
}
}
func test_tables() throws {
let dbQueue = try makeMyDatabase()
assertSnapshot(of: dbQueue, as: .dumpTables(["player", "team"]))
}
func test_request() throws {
let dbQueue = try makeMyDatabase()
try dbQueue.read { db in
assertSnapshot(of: Player.all(), as: .dump(db))
}
}
func test_sql() throws {
let dbQueue = try makeMyDatabase()
try dbQueue.read { db in
assertSnapshot(of: "SELECT * FROM player ORDER BY id", as: .dump(db))
}
}
}[GRDB]: http://github.com/groue/GRDB.swift [SnapshotTesting]: https://github.com/pointfreeco/swift-snapshot-testing [Documentation]: https://swiftpackageindex.com/groue/GRDBSnapshotTesting/documentation
Package Metadata
Repository: groue/grdbsnapshottesting
Default branch: main
README: README.md