From e7938e9193ba1a39aab0e614bb3bf682508685b2 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 30 Apr 2026 00:28:29 -0500 Subject: test: add gloss-drill test suite (red phase) Four test files plus a small testutil for toggling the `org-drill' feature flag. All 10 tests fail at this commit because the implementation is still a stub. The suite covers Normal (untagged entries get the tag and property), Boundary (empty file, idempotency, untag never-tagged), and Error (org-drill not installed). The error path also asserts the file is left untouched. Untag-all is tested under both feature states because the user might want to remove tags after uninstalling org-drill. --- ...loss-drill--export-all-no-orgdrill-installed.el | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/test-gloss-drill--export-all-no-orgdrill-installed.el (limited to 'tests/test-gloss-drill--export-all-no-orgdrill-installed.el') diff --git a/tests/test-gloss-drill--export-all-no-orgdrill-installed.el b/tests/test-gloss-drill--export-all-no-orgdrill-installed.el new file mode 100644 index 0000000..f8f4967 --- /dev/null +++ b/tests/test-gloss-drill--export-all-no-orgdrill-installed.el @@ -0,0 +1,38 @@ +;;; test-gloss-drill--export-all-no-orgdrill-installed.el --- Error tests for missing org-drill -*- lexical-binding: t -*- + +;; SPDX-License-Identifier: GPL-3.0-or-later + +;;; Commentary: +;; Tests for `gloss-drill-export-all' covering the Error case where +;; `org-drill' is not installed. The function must raise `user-error' +;; with an install hint and must not touch `gloss-file'. + +;;; Code: + +(require 'ert) +(require 'gloss-drill) +(require 'testutil-gloss) +(require 'testutil-gloss-drill) + +(ert-deftest test-gloss-drill-export-all-without-org-drill-raises-user-error () + "Error: missing `org-drill' raises `user-error' with an install hint." + (gloss-test--with-temp-glossary gloss-test--sample-content + (gloss-test--without-org-drill-feature + (let ((err (should-error (gloss-drill-export-all) :type 'user-error))) + (should (string-match-p "org-drill" (error-message-string err))))))) + +(ert-deftest test-gloss-drill-export-all-without-org-drill-leaves-file-untouched () + "Error: missing `org-drill' must not modify the glossary file." + (gloss-test--with-temp-glossary gloss-test--sample-content + (gloss-test--without-org-drill-feature + (let ((before (with-temp-buffer + (insert-file-contents gloss-file) + (buffer-string)))) + (ignore-errors (gloss-drill-export-all)) + (let ((after (with-temp-buffer + (insert-file-contents gloss-file) + (buffer-string)))) + (should (equal before after))))))) + +(provide 'test-gloss-drill--export-all-no-orgdrill-installed) +;;; test-gloss-drill--export-all-no-orgdrill-installed.el ends here -- cgit v1.2.3