ndb: add initial search interface

Still needs updating because of the tuple array
This commit is contained in:
William Casarin
2023-12-02 15:05:15 -08:00
parent 6b8cf51720
commit 9502fc30ba
3 changed files with 65 additions and 0 deletions

View File

@@ -81,6 +81,23 @@ final class NdbTests: XCTestCase {
}
func test_ndb_seach() throws {
do {
let ndb = try! Ndb(path: db_dir)!
let ok = ndb.process_events(test_wire_events)
XCTAssertTrue(ok)
}
do {
let ndb = try! Ndb(path: db_dir)!
let note_ids = ndb.text_search(query: "barked")
XCTAssertEqual(note_ids.count, 1)
let expected_note_id = NoteId(hex: "b17a540710fe8495b16bfbaf31c6962c4ba8387f3284a7973ad523988095417e")!
let note_id = ndb.lookup_note_by_key(note_ids[0]).map({ n in n?.id }).value
XCTAssertEqual(note_id, .some(expected_note_id))
}
}
func test_ndb_note() throws {
let note = NdbNote.owned_from_json(json: test_contact_list_json)
XCTAssertNotNil(note)