Conversation
hywiki-tests--referent-cache-test - Add to test saving and reloading a bookmark referent from cache. hywiki-tests--save-referent-org-id - Fix to call 'hywiki-add-referent' around 'hywiki-add-org-id' since interactive runs of this test without that wrapper return nil for comparison to the expected (cons 'org-id "generated-org-id".
| (goto-char (point-max)) | ||
| (hywiki-add-org-id wiki-word-non-page) | ||
| (hywiki-get-referent wiki-word-non-page))) | ||
| (hywiki-add-referent wiki-word-non-page |
There was a problem hiding this comment.
This is interesting. Adding the referent using hywiki-add-referent is basically what the test is about so doing that explicitly will not test the right thing. The tests purpose is to verify that hywiki-add-org-id will call hywiki-add-referent here.
With this version:
; TEST: Old test for checking verification
(ert-deftest hywiki-tests--save-referent-org-id-alt ()
"Verify saving and loading a referent org id works."
(hywiki-tests--referent-test-with-cache
(cons 'org-id "generated-org-id")
(save-excursion
(let ((filea (make-temp-file "hypb" nil ".org")))
(unwind-protect
(with-current-buffer (find-file filea)
(hywiki-tests--insert "* header\n")
(mocklet (((org-id-get) => "generated-org-id"))
(goto-char (point-max))
;; 1 - (hywiki-get-referent-hasht)
;; 2 - (should-not (hywiki-get-referent wiki-word-non-page))
(hywiki-add-org-id wiki-word-non-page)))
(hy-delete-file-and-buffer filea))))))
When I run it in my development Emacs it fails as you have seen at your end but when I run it in a clean docker environment also interactively it works.
Even more confusing is that if I uncomment either or line beinning with ";; 1" or ";; 2" the test does also work in my development Emacs. (And continues to work in docker.)
And if that was not enough - In the commited version the call to hywiki-add.-org-id will actually call hywiki-add-referent before hywiki-add-referent is called from the test code. (Since the return value of hywiki-add-org-id comes from the call to hywiki-add-referent. Bah.)
Anyway - I think having the call to hywiki-add-referent in the test is misleading. We need to figure out why this is happening.
hywiki-tests--referent-cache-test - Add to test saving and reloading a bookmark referent from cache.
hywiki-tests--save-referent-org-id - Fix to call 'hywiki-add-referent' around 'hywiki-add-org-id' since interactive runs of this test without that wrapper return nil for comparison to the expected (cons 'org-id "generated-org-id".