Skip to content

Add test for hyrolo-add#942

Open
matsl wants to merge 1 commit intomasterfrom
add_hyrolo_tests
Open

Add test for hyrolo-add#942
matsl wants to merge 1 commit intomasterfrom
add_hyrolo_tests

Conversation

@matsl
Copy link
Copy Markdown
Collaborator

@matsl matsl commented Apr 24, 2026

What

Add test for hyrolo-add

  • test/hyrolo-tests.el (hyrolo-tests--add--error-cases): New test.
    (hyrolo-tests--add-items-at-multiple-levels):
    (hyrolo-tests--add-items-interactive): Fix quotes in docstring.

  • hyrolo.el (hyrolo-add): Handle not existing file error case.

Why

More test coverage for hyrolo.

There is also a potential problem with

(hyrolo-add <item> <file-that-does-not-exists>)

The file is created (or at least a buffer for it). Not sure if it is a
feature or an error. This PR views it as an error and adds a check to
hyrolo-add to signal an error if adding an item to a file that does
not exist.

Note

Testing write and read properties of files using root as user is
problematic since it behaves different for root than for a regular
user. This PR solved it by mocking the checks.

This shows a bigger problem. In the best of worlds we should be
running the tests as a regular user. That will require some work to
implement in our current setup.

* test/hyrolo-tests.el (hyrolo-tests--add--error-cases): New test.
(hyrolo-tests--add-items-at-multiple-levels):
(hyrolo-tests--add-items-interactive): Fix quotes in docstring.

* hyrolo.el (hyrolo-add): Handle not existing file error case.
@matsl matsl requested a review from rswgnu April 24, 2026 17:47
@rswgnu
Copy link
Copy Markdown
Owner

rswgnu commented Apr 25, 2026

If the first file in hyrolo-file-list does not exist, the file should be created and the entry added when hyrolo-add is called. Hyperbole should initialize that variable to non-null if needed as well.

@matsl
Copy link
Copy Markdown
Collaborator Author

matsl commented Apr 25, 2026

If the first file in hyrolo-file-list does not exist, the file should be created and the entry added when hyrolo-add is called. Hyperbole should initialize that variable to non-null if needed as well.

That is a good test to add and it breaks my fix. Good catch. I'll add that test and fix hyrolo-add.

Since we have a defcustom for hyrolo-file-list that initializes it, that should already be covered by that!?

But coming back to the test. What should be the behavior when adding an item to a file that does not exist but is not the first file in hyrolo-file-list? Shall it too be created or shall hyrolo-add signal an error?

Related: Do we need to check better that the first file in hyrolo-file-list is a "user-specific hyrolo file" and not just the first file that hyrolo-get-file-list returns?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants