From d313c37f14511564849c70c564c14ca51bd4ae7c Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 30 Apr 2026 01:07:44 -0500 Subject: test: add gloss secondary commands test suite (red phase) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Six test files for the remaining stub commands. All 14 tests fail at this commit because the implementations are stubs. `gloss--add-finish-internal' (the pure save side of `gloss-add') gets N/B/E coverage on validation and the persistence side effect. `gloss--stats-text' (the pure stats string formatter) covers empty, populated, and missing-file cases. The interactive commands (`gloss-edit', `gloss-list-terms', `gloss-reload', `gloss-drill-export') get smoke tests only — the design treats them as mode-glue with 70% coverage targets, since prompts and `switch-to-buffer' are framework behaviour Emacs already tests. Two error-path tests assert the message contains a specific substring, not just that `user-error' was raised. The stubs raise `user-error' too, so a bare `should-error' would pass for the wrong reason. The substring check anchors red against the real error path. --- tests/test-gloss--stats-text.el | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/test-gloss--stats-text.el (limited to 'tests/test-gloss--stats-text.el') diff --git a/tests/test-gloss--stats-text.el b/tests/test-gloss--stats-text.el new file mode 100644 index 0000000..32093b1 --- /dev/null +++ b/tests/test-gloss--stats-text.el @@ -0,0 +1,40 @@ +;;; test-gloss--stats-text.el --- Tests for gloss--stats-text -*- lexical-binding: t -*- + +;; SPDX-License-Identifier: GPL-3.0-or-later + +;;; Commentary: +;; Tests for the pure helper `gloss--stats-text' which formats a +;; multi-line stats summary. Drill-tagged count walks the org file via +;; the same primitives as `gloss-drill', so this also indirectly +;; exercises that integration. + +;;; Code: + +(require 'ert) +(require 'gloss) +(require 'testutil-gloss) + +(ert-deftest test-gloss-stats-text-empty-glossary-reports-zero () + "Boundary: empty glossary file reports zero terms." + (gloss-test--with-temp-glossary "#+TITLE: Glossary\n#+STARTUP: showall\n" + (let ((text (gloss--stats-text))) + (should (string-match-p "Total terms: +0" text)) + (should (string-match-p "Drill-tagged: +0" text))))) + +(ert-deftest test-gloss-stats-text-populated-glossary-counts-terms () + "Normal: populated glossary reports total terms and source breakdown." + (gloss-test--with-temp-glossary gloss-test--sample-content + (let ((text (gloss--stats-text))) + (should (string-match-p "Total terms: +2" text)) + (should (string-match-p "wiktionary=2" text)) + (should (string-match-p "File size:" text)) + (should (string-match-p "Cache mtime:" text))))) + +(ert-deftest test-gloss-stats-text-missing-file-reports-zero-and-never () + "Error: missing glossary file reports zero terms and \"never\" mtime." + (gloss-test--with-missing-glossary + (let ((text (gloss--stats-text))) + (should (string-match-p "Total terms: +0" text))))) + +(provide 'test-gloss--stats-text) +;;; test-gloss--stats-text.el ends here -- cgit v1.2.3