From f0b8bbfe7f590aa5204f72f8522d7df11e42d385 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Thu, 15 Jan 2026 19:15:56 +0100 Subject: [PATCH] add test_note_store_get_notebook_by_id --- application/tests/test-store.c | 18 ++++++++++++++++++ application/tests/test-store.h | 1 + application/tests/testmain.c | 1 + 3 files changed, 20 insertions(+) diff --git a/application/tests/test-store.c b/application/tests/test-store.c index 2fd663d..f2e4fae 100644 --- a/application/tests/test-store.c +++ b/application/tests/test-store.c @@ -270,3 +270,21 @@ CX_TEST(test_note_store_save_resource_async) { ui_close(obj); } } + +CX_TEST(test_note_store_get_notebook_by_id) { + // it is important that this test is run after some other tests + // created some resources + CX_TEST_DO { + CX_TEST_ASSERT(!note_store_reload()); + NoteStore *store = note_store_get(); + CX_TEST_ASSERT(store && store->root && store->root->children); + CX_TEST_ASSERT(cxListSize(store->root->children) > 0); + + CxIterator i = cxListIterator(store->root->children); + cx_foreach(Resource *, res, i) { + Resource *xres = note_store_get_notebook_by_id(res->resource_id); + CX_TEST_ASSERT(res == xres); + } + } +} + diff --git a/application/tests/test-store.h b/application/tests/test-store.h index ed281ce..0e12cdd 100644 --- a/application/tests/test-store.h +++ b/application/tests/test-store.h @@ -39,6 +39,7 @@ CX_TEST(test_init_note_store); CX_TEST(test_note_store_create_default); CX_TEST(test_user_settings_is_valid); +CX_TEST(test_note_store_get_notebook_by_id); CX_TEST(test_note_store_reload); CX_TEST(test_note_store_new_resource_async); CX_TEST(test_note_store_new_notebook_async); diff --git a/application/tests/testmain.c b/application/tests/testmain.c index 59a68ae..de17487 100644 --- a/application/tests/testmain.c +++ b/application/tests/testmain.c @@ -60,6 +60,7 @@ int main(int argc, char **argv) { cx_test_register(suite, test_note_store_new_resource_async); cx_test_register(suite, test_note_store_new_notebook_async); cx_test_register(suite, test_note_store_save_resource_async); + cx_test_register(suite, test_note_store_get_notebook_by_id); cx_test_register(suite, test_parse_markdown_para); cx_test_register(suite, test_parse_markdown_formatting_simple); -- 2.47.3