ndb: add safemode so we don't instantly crash on bad dbs
Fixes: https://github.com/damus-io/damus/issues/1741
This commit is contained in:
@@ -55,13 +55,13 @@ final class NdbTests: XCTestCase {
|
||||
func test_ndb_init() {
|
||||
|
||||
do {
|
||||
let ndb = try! Ndb(path: db_dir)!
|
||||
let ndb = Ndb(path: db_dir)!
|
||||
let ok = ndb.process_events(test_wire_events)
|
||||
XCTAssertTrue(ok)
|
||||
}
|
||||
|
||||
do {
|
||||
let ndb = try! Ndb(path: db_dir)!
|
||||
let ndb = Ndb(path: db_dir)!
|
||||
let id = NoteId(hex: "d12c17bde3094ad32f4ab862a6cc6f5c289cfe7d5802270bdf34904df585f349")!
|
||||
let txn = NdbTxn(ndb: ndb)
|
||||
let note = ndb.lookup_note_with_txn(id: id, txn: txn)
|
||||
@@ -83,13 +83,13 @@ final class NdbTests: XCTestCase {
|
||||
|
||||
func test_ndb_seach() throws {
|
||||
do {
|
||||
let ndb = try! Ndb(path: db_dir)!
|
||||
let ndb = Ndb(path: db_dir)!
|
||||
let ok = ndb.process_events(test_wire_events)
|
||||
XCTAssertTrue(ok)
|
||||
}
|
||||
|
||||
do {
|
||||
let ndb = try! Ndb(path: db_dir)!
|
||||
let ndb = Ndb(path: db_dir)!
|
||||
let note_ids = ndb.text_search(query: "barked")
|
||||
XCTAssertEqual(note_ids.count, 1)
|
||||
let expected_note_id = NoteId(hex: "b17a540710fe8495b16bfbaf31c6962c4ba8387f3284a7973ad523988095417e")!
|
||||
|
||||
Reference in New Issue
Block a user