diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-30 01:03:13 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-30 01:03:13 -0500 |
| commit | 540d805bd917a37d0fafa5393f3bfc7e3603570e (patch) | |
| tree | 35b79a7a628a4a0e1e34a0bf3fa46bdd6ab33dc5 /tests/test-gloss--orchestrate-fetch-result.el | |
| parent | 5b5ac68e138950e2f8d502e22350a62570da88a6 (diff) | |
| download | gloss-540d805bd917a37d0fafa5393f3bfc7e3603570e.tar.gz gloss-540d805bd917a37d0fafa5393f3bfc7e3603570e.zip | |
test: add gloss orchestration core test suite (red phase)
Two test files for the orchestration core. All 13 tests fail at this
commit because the implementation is still stubbed.
`gloss--orchestrate-fetch-result' gets full N/B/E coverage on the
decision matrix: single def, multi def, the >1 boundary, empty defs
with each combination of :no-defs and :failed populated, and the
all-empty degenerate case.
`gloss--lookup-flow' covers cache hit (no fetch), cache miss with one
def (auto-save), cache miss with multiple (picker), cancelled picker
(no save), no-defs error, and the force-fetch override that bypasses
the cache. Mocks live at network and UI boundaries; persistence runs
against a real temp glossary so the save side effect is validated.
Diffstat (limited to 'tests/test-gloss--orchestrate-fetch-result.el')
| -rw-r--r-- | tests/test-gloss--orchestrate-fetch-result.el | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/test-gloss--orchestrate-fetch-result.el b/tests/test-gloss--orchestrate-fetch-result.el new file mode 100644 index 0000000..b4a4cf8 --- /dev/null +++ b/tests/test-gloss--orchestrate-fetch-result.el @@ -0,0 +1,67 @@ +;;; test-gloss--orchestrate-fetch-result.el --- Tests for gloss--orchestrate-fetch-result -*- lexical-binding: t -*- + +;; SPDX-License-Identifier: GPL-3.0-or-later + +;;; Commentary: +;; Tests for the pure pattern-matcher `gloss--orchestrate-fetch-result'. +;; It maps a `gloss-fetch-definitions' result plist to a decision +;; symbol that the lookup flow then dispatches on. Full N/B/E +;; coverage on the full decision matrix. + +;;; Code: + +(require 'ert) +(require 'gloss) + +(ert-deftest test-gloss-orchestrate-fetch-result-single-def-returns-auto-save () + "Normal: exactly one definition returns :auto-save." + (let ((result '(:defs ((:source wiktionary :text "Only sense.")) + :no-defs nil + :failed nil))) + (should (eq (gloss--orchestrate-fetch-result result) :auto-save)))) + +(ert-deftest test-gloss-orchestrate-fetch-result-multi-def-returns-pick () + "Normal: more than one definition returns :pick." + (let ((result '(:defs ((:source wiktionary :text "First.") + (:source wiktionary :text "Second.") + (:source wiktionary :text "Third.")) + :no-defs nil + :failed nil))) + (should (eq (gloss--orchestrate-fetch-result result) :pick)))) + +(ert-deftest test-gloss-orchestrate-fetch-result-two-defs-returns-pick () + "Boundary: exactly two definitions returns :pick (above the >1 threshold)." + (let ((result '(:defs ((:source wiktionary :text "A.") + (:source wiktionary :text "B.")) + :no-defs nil + :failed nil))) + (should (eq (gloss--orchestrate-fetch-result result) :pick)))) + +(ert-deftest test-gloss-orchestrate-fetch-result-only-no-defs-returns-error-no-defs () + "Boundary: no defs and only :no-defs sources returns :error-no-defs." + (let ((result '(:defs nil + :no-defs (wiktionary) + :failed nil))) + (should (eq (gloss--orchestrate-fetch-result result) :error-no-defs)))) + +(ert-deftest test-gloss-orchestrate-fetch-result-only-failed-returns-error-failed () + "Boundary: no defs and only :failed sources returns :error-failed." + (let ((result '(:defs nil + :no-defs nil + :failed (wiktionary)))) + (should (eq (gloss--orchestrate-fetch-result result) :error-failed)))) + +(ert-deftest test-gloss-orchestrate-fetch-result-mixed-no-defs-and-failed-returns-error-mixed () + "Boundary: no defs but BOTH :no-defs and :failed populated returns :error-mixed." + (let ((result '(:defs nil + :no-defs (wiktionary) + :failed (dictionary-api)))) + (should (eq (gloss--orchestrate-fetch-result result) :error-mixed)))) + +(ert-deftest test-gloss-orchestrate-fetch-result-all-empty-returns-error-no-defs () + "Error: degenerate result with all three keys empty returns :error-no-defs." + (let ((result '(:defs nil :no-defs nil :failed nil))) + (should (eq (gloss--orchestrate-fetch-result result) :error-no-defs)))) + +(provide 'test-gloss--orchestrate-fetch-result) +;;; test-gloss--orchestrate-fetch-result.el ends here |
