diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-30 00:28:29 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-30 00:28:29 -0500 |
| commit | e7938e9193ba1a39aab0e614bb3bf682508685b2 (patch) | |
| tree | b1b64f14c5d5de5defb1a8f418ed6fe08b57ecd9 /tests/test-gloss-drill--untag-all.el | |
| parent | 29c21851bddf76c5fd659d4225bb426fc1396750 (diff) | |
| download | gloss-e7938e9193ba1a39aab0e614bb3bf682508685b2.tar.gz gloss-e7938e9193ba1a39aab0e614bb3bf682508685b2.zip | |
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.
Diffstat (limited to 'tests/test-gloss-drill--untag-all.el')
| -rw-r--r-- | tests/test-gloss-drill--untag-all.el | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/test-gloss-drill--untag-all.el b/tests/test-gloss-drill--untag-all.el new file mode 100644 index 0000000..7fe9986 --- /dev/null +++ b/tests/test-gloss-drill--untag-all.el @@ -0,0 +1,56 @@ +;;; test-gloss-drill--untag-all.el --- Tests for gloss-drill-untag-all -*- lexical-binding: t -*- + +;; SPDX-License-Identifier: GPL-3.0-or-later + +;;; Commentary: +;; Tests for `gloss-drill-untag-all' covering Normal (export then untag), +;; Boundary (untag when nothing was tagged), and the no-org-drill-needed +;; case (untag must work without `org-drill' installed, since the user +;; might want to remove tags after uninstalling). + +;;; Code: + +(require 'ert) +(require 'gloss-drill) +(require 'testutil-gloss) +(require 'testutil-gloss-drill) + +(defun gloss-test--no-drill-tags-or-properties-p () + "Return non-nil when no top-level entry carries :drill: or DRILL_CARD_TYPE. +Reads the file fresh from disk." + (with-current-buffer (find-file-noselect gloss-file) + (revert-buffer t t t) + (let ((dirty nil)) + (org-map-entries + (lambda () + (when (= 1 (org-current-level)) + (when (or (member "drill" (org-get-tags nil t)) + (org-entry-get nil "DRILL_CARD_TYPE")) + (setq dirty t))))) + (not dirty)))) + +(ert-deftest test-gloss-drill-untag-all-removes-tag-and-property () + "Normal: untag-all removes :drill: and :DRILL_CARD_TYPE: from every entry." + (gloss-test--with-temp-glossary gloss-test--sample-content + (gloss-test--with-org-drill-feature + (gloss-drill-export-all) + (gloss-drill-untag-all) + (should (gloss-test--no-drill-tags-or-properties-p))))) + +(ert-deftest test-gloss-drill-untag-all-no-op-when-nothing-tagged () + "Boundary: untag-all on never-tagged entries is a no-op, no error." + (gloss-test--with-temp-glossary gloss-test--sample-content + (gloss-drill-untag-all) + (should (gloss-test--no-drill-tags-or-properties-p)))) + +(ert-deftest test-gloss-drill-untag-all-works-without-org-drill-installed () + "Boundary: untag-all does NOT require org-drill to be installed." + (gloss-test--with-temp-glossary gloss-test--sample-content + (gloss-test--with-org-drill-feature + (gloss-drill-export-all)) + (gloss-test--without-org-drill-feature + (gloss-drill-untag-all) + (should (gloss-test--no-drill-tags-or-properties-p))))) + +(provide 'test-gloss-drill--untag-all) +;;; test-gloss-drill--untag-all.el ends here |
