From 1e2da6b1a463492ada31ce473414289e761519ca Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 28 Apr 2026 14:31:34 -0500 Subject: refactor: extract missing-glossary test helper Four tests across lookup, list, find-buffer-position, and first-call-creates-file shared the same boilerplate. Each let-bound gloss-file to a randomized nonexistent path, wrapped in unwind-protect, reset the cache, and cleaned up file and buffer afterward. Extracted as gloss-test--with-missing-glossary in testutil-gloss.el, parallel to the existing gloss-test--with-temp-glossary. The four call sites drop from 8-10 lines each to 2-3. Tested by running the full 32-test suite. All 32 pass in 0.21 seconds. --- tests/test-gloss-core--lookup.el | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'tests/test-gloss-core--lookup.el') diff --git a/tests/test-gloss-core--lookup.el b/tests/test-gloss-core--lookup.el index a1986a7..0e044ca 100644 --- a/tests/test-gloss-core--lookup.el +++ b/tests/test-gloss-core--lookup.el @@ -59,15 +59,9 @@ (ert-deftest test-gloss-core-lookup-missing-file-returns-nil () "Error: lookup before any save returns nil (file does not exist)." - (let ((gloss-file (concat temporary-file-directory "gloss-nonexistent-" - (number-to-string (random 100000)) ".org"))) - (unwind-protect - (progn - (gloss-core--cache-reset) - (should-not (file-exists-p gloss-file)) - (should-not (gloss-core-lookup "anything"))) - (gloss-core--cache-reset) - (when (file-exists-p gloss-file) (delete-file gloss-file))))) + (gloss-test--with-missing-glossary + (should-not (file-exists-p gloss-file)) + (should-not (gloss-core-lookup "anything")))) (provide 'test-gloss-core--lookup) ;;; test-gloss-core--lookup.el ends here -- cgit v1.2.3