From ff12d8bd7ef978ff870f1f4bca980e762b7aac83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Fri, 25 Jul 2025 18:46:17 -0700 Subject: [PATCH] Prevent crash from ndb search test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changelog-None Signed-off-by: Daniel D’Aquino --- nostrdb/Test/NdbTests.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nostrdb/Test/NdbTests.swift b/nostrdb/Test/NdbTests.swift index dd1c3bf3..e4f82c05 100644 --- a/nostrdb/Test/NdbTests.swift +++ b/nostrdb/Test/NdbTests.swift @@ -81,7 +81,7 @@ final class NdbTests: XCTestCase { } - func test_ndb_seach() throws { + func test_ndb_search() throws { do { let ndb = Ndb(path: db_dir)! let ok = ndb.process_events(test_wire_events) @@ -93,6 +93,10 @@ final class NdbTests: XCTestCase { let note_ids = ndb.text_search(query: "barked") XCTAssertEqual(note_ids.count, 1) let expected_note_id = NoteId(hex: "b17a540710fe8495b16bfbaf31c6962c4ba8387f3284a7973ad523988095417e")! + guard note_ids.count > 0 else { + XCTFail("Expected at least one note to be found") + return + } let note_id = ndb.lookup_note_by_key(note_ids[0])?.map({ n in n?.id }).value XCTAssertEqual(note_id, .some(expected_note_id)) }