aboutsummaryrefslogtreecommitdiff
path: root/tests/test-gloss-fetch--definitions-timeout-returns-unreachable.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-28 18:10:17 -0500
committerCraig Jennings <c@cjennings.net>2026-04-28 19:09:22 -0500
commitdc0db0f0e12d8af6d1d54a5dde1cd16cf890a33d (patch)
tree9d174e136d62981c1bded06fe423d08bddc91e04 /tests/test-gloss-fetch--definitions-timeout-returns-unreachable.el
parent3a846506399dc12ab219bfa8047947c122dd1d04 (diff)
downloadgloss-dc0db0f0e12d8af6d1d54a5dde1cd16cf890a33d.tar.gz
gloss-dc0db0f0e12d8af6d1d54a5dde1cd16cf890a33d.zip
test: add gloss-fetch test suite (red phase)
Eight test files cover the network layer's public and internal contract. The boundary mock is `url-retrieve-synchronously', wrapped by a small `testutil-gloss-fetch' helper that builds response buffers in the shape the url library returns. Tests cover the 200 happy paths (anaphora and SBIR fixtures), 404 to :no-defs, 5xx and 4xx-other and malformed JSON to :server-error, 429 to :rate-limited, nil-from-url to :unreachable, the libxml availability probe (one-shot, signals user-error when absent), the registry walker ordering, and the pure HTML strip helper across N/B/E. Tests fail on missing `gloss-fetch--*' functions, as expected for red phase.
Diffstat (limited to 'tests/test-gloss-fetch--definitions-timeout-returns-unreachable.el')
-rw-r--r--tests/test-gloss-fetch--definitions-timeout-returns-unreachable.el44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/test-gloss-fetch--definitions-timeout-returns-unreachable.el b/tests/test-gloss-fetch--definitions-timeout-returns-unreachable.el
new file mode 100644
index 0000000..881b783
--- /dev/null
+++ b/tests/test-gloss-fetch--definitions-timeout-returns-unreachable.el
@@ -0,0 +1,44 @@
+;;; test-gloss-fetch--definitions-timeout-returns-unreachable.el --- timeout path -*- lexical-binding: t -*-
+
+;; SPDX-License-Identifier: GPL-3.0-or-later
+
+;;; Commentary:
+;; A timeout (or any other transport-level failure) makes
+;; `url-retrieve-synchronously' return nil; the source maps to
+;; :unreachable, which joins :failed at the rollup.
+
+;;; Code:
+
+(require 'ert)
+(require 'cl-lib)
+(require 'gloss-fetch)
+(require 'testutil-gloss-fetch)
+
+(ert-deftest test-gloss-fetch-definitions-timeout-rolls-up-to-failed ()
+ "Normal: nil from url-retrieve-synchronously rolls up to :failed."
+ (gloss-fetch-test--with-mocked-url
+ (lambda (_url) nil)
+ (let ((result (gloss-fetch-definitions "anaphora")))
+ (should (eq (car result) :empty))
+ (should (member 'wiktionary (plist-get result :failed)))
+ (should-not (plist-get result :no-defs)))))
+
+(ert-deftest test-gloss-fetch-definitions-timeout-marks-source-unreachable ()
+ "Boundary: per-source status is :unreachable, distinct from :server-error."
+ (gloss-fetch-test--with-mocked-url
+ (lambda (_url) nil)
+ (let* ((per-source (gloss-fetch--collect "anaphora"))
+ (entry (car per-source)))
+ (should (eq (plist-get entry :source) 'wiktionary))
+ (should (eq (plist-get entry :status) :unreachable)))))
+
+(ert-deftest test-gloss-fetch-definitions-error-signal-marks-source-unreachable ()
+ "Error: a signaled error inside url-retrieve-synchronously also yields :unreachable."
+ (gloss-fetch-test--with-mocked-url
+ (lambda (_url) (error "Connection refused"))
+ (let* ((per-source (gloss-fetch--collect "anaphora"))
+ (entry (car per-source)))
+ (should (eq (plist-get entry :status) :unreachable)))))
+
+(provide 'test-gloss-fetch--definitions-timeout-returns-unreachable)
+;;; test-gloss-fetch--definitions-timeout-returns-unreachable.el ends here