aboutsummaryrefslogtreecommitdiff
path: root/tests/test-testutil-gloss--load-wiktionary-fixture.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-28 18:08:09 -0500
committerCraig Jennings <c@cjennings.net>2026-04-28 18:08:09 -0500
commit3a846506399dc12ab219bfa8047947c122dd1d04 (patch)
treeca547a7abc756e32398dc493c97cc8874367dfe9 /tests/test-testutil-gloss--load-wiktionary-fixture.el
parent166d3bde50718eacd51c75cb82246988d9ec0151 (diff)
downloadgloss-3a846506399dc12ab219bfa8047947c122dd1d04.tar.gz
gloss-3a846506399dc12ab219bfa8047947c122dd1d04.zip
test: add Wiktionary fixture loader helper
Append `gloss-test--load-wiktionary-fixture' to tests/testutil-gloss.el. It takes a fixture name (e.g. "anaphora") and returns the raw JSON body from tests/fixtures/wiktionary-NAME.json, or signals `error' with the full path when the file isn't there. The helper resolves the fixtures directory from a `defconst' captured at load time. That way it works the same whether a test file requires testutil-gloss directly or pulls it in transitively through `make test'. Three ERT cases under tests/test-testutil-gloss--load-wiktionary-fixture.el cover Normal (anaphora loads as a non-empty JSON string), Boundary (the smallest fixture, 404, loads), and Error (a missing fixture raises with the path embedded in the message). Verified with `make test': 35 passed, 0 unexpected.
Diffstat (limited to 'tests/test-testutil-gloss--load-wiktionary-fixture.el')
-rw-r--r--tests/test-testutil-gloss--load-wiktionary-fixture.el37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/test-testutil-gloss--load-wiktionary-fixture.el b/tests/test-testutil-gloss--load-wiktionary-fixture.el
new file mode 100644
index 0000000..daf24af
--- /dev/null
+++ b/tests/test-testutil-gloss--load-wiktionary-fixture.el
@@ -0,0 +1,37 @@
+;;; test-testutil-gloss--load-wiktionary-fixture.el --- Tests for fixture loader -*- lexical-binding: t -*-
+
+;; SPDX-License-Identifier: GPL-3.0-or-later
+
+;;; Commentary:
+;; Tests for `gloss-test--load-wiktionary-fixture' covering
+;; Normal/Boundary/Error cases.
+
+;;; Code:
+
+(require 'ert)
+(require 'testutil-gloss)
+
+(ert-deftest test-testutil-gloss-load-wiktionary-fixture-existing-returns-string ()
+ "Normal: an existing fixture loads as a non-empty JSON string."
+ (let ((body (gloss-test--load-wiktionary-fixture "anaphora")))
+ (should (stringp body))
+ (should (> (length body) 0))
+ (should (string-prefix-p "{" body))))
+
+(ert-deftest test-testutil-gloss-load-wiktionary-fixture-smallest-fixture-loads ()
+ "Boundary: the 404 error-body fixture (smallest) loads as a string."
+ (let ((body (gloss-test--load-wiktionary-fixture "404")))
+ (should (stringp body))
+ (should (> (length body) 0))
+ (should (string-match-p "404" body))))
+
+(ert-deftest test-testutil-gloss-load-wiktionary-fixture-missing-raises-error ()
+ "Error: a missing fixture signals `error' with the path in the message."
+ (let* ((name "does-not-exist-xyzzy")
+ (err (should-error (gloss-test--load-wiktionary-fixture name)
+ :type 'error)))
+ (should (string-match-p (format "wiktionary-%s\\.json" name)
+ (error-message-string err)))))
+
+(provide 'test-testutil-gloss--load-wiktionary-fixture)
+;;; test-testutil-gloss--load-wiktionary-fixture.el ends here