diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-28 19:13:05 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-28 19:13:05 -0500 |
| commit | 01b75599a500d6276a962b47744166abb25d846c (patch) | |
| tree | 2d4278894f35ac79c16495c09c7c8649f07bccbb /tests/test-gloss-fetch--definitions-500-returns-server-error.el | |
| parent | 3491d9b799f9678f6095149a348330e2a05a1924 (diff) | |
| download | gloss-main.tar.gz gloss-main.zip | |
The previous shape (:ok DEFS) | (:empty :no-defs (...) :failed (...)) was malformed as a plist. The :empty tag at position 0 shifted the plist alignment. plist-get on :no-defs or :failed returned nil. Tests had to use (plist-get (cdr result) ...) as a workaround.
The new shape is a uniform plist with all three keys always present: (:defs DEFS :no-defs (SYM ...) :failed (SYM ...)). Consumers branch on whether :defs is non-empty. There is no tag. plist-get works uniformly across success and empty cases.
Updated gloss-fetch.el (rollup function and docstrings), 7 test files, and the design doc (docs/design/gloss.org ยง Error Handling).
Tested by `make test`. 65 tests pass in 0.36 seconds.
Diffstat (limited to 'tests/test-gloss-fetch--definitions-500-returns-server-error.el')
| -rw-r--r-- | tests/test-gloss-fetch--definitions-500-returns-server-error.el | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/test-gloss-fetch--definitions-500-returns-server-error.el b/tests/test-gloss-fetch--definitions-500-returns-server-error.el index 20e988b..54664f3 100644 --- a/tests/test-gloss-fetch--definitions-500-returns-server-error.el +++ b/tests/test-gloss-fetch--definitions-500-returns-server-error.el @@ -21,9 +21,9 @@ (gloss-fetch-test--status-response "HTTP/1.1 500 Internal Server Error" "Server is sad.")) (let ((result (gloss-fetch-definitions "anaphora"))) - (should (eq (car result) :empty)) - (should (member 'wiktionary (plist-get (cdr result) :failed))) - (should-not (plist-get (cdr result) :no-defs))))) + (should-not (plist-get result :defs)) + (should (member 'wiktionary (plist-get result :failed))) + (should-not (plist-get result :no-defs))))) (ert-deftest test-gloss-fetch-definitions-503-rolls-up-to-failed () "Normal: HTTP 503 maps the source to :server-error (in :failed)." @@ -31,16 +31,16 @@ (lambda (_url) (gloss-fetch-test--status-response "HTTP/1.1 503 Service Unavailable" "")) (let ((result (gloss-fetch-definitions "anaphora"))) - (should (eq (car result) :empty)) - (should (member 'wiktionary (plist-get (cdr result) :failed)))))) + (should-not (plist-get result :defs)) + (should (member 'wiktionary (plist-get result :failed)))))) (ert-deftest test-gloss-fetch-definitions-malformed-json-rolls-up-to-failed () "Boundary: a 200 with non-JSON body also maps to :server-error." (gloss-fetch-test--with-mocked-url (lambda (_url) (gloss-fetch-test--ok-response "<html>not json</html>")) (let ((result (gloss-fetch-definitions "anaphora"))) - (should (eq (car result) :empty)) - (should (member 'wiktionary (plist-get (cdr result) :failed)))))) + (should-not (plist-get result :defs)) + (should (member 'wiktionary (plist-get result :failed)))))) (ert-deftest test-gloss-fetch-definitions-400-rolls-up-to-failed () "Error: HTTP 400 (4xx other than 404/429) maps to :server-error (in :failed)." @@ -48,8 +48,8 @@ (lambda (_url) (gloss-fetch-test--status-response "HTTP/1.1 400 Bad Request" "")) (let ((result (gloss-fetch-definitions "anaphora"))) - (should (eq (car result) :empty)) - (should (member 'wiktionary (plist-get (cdr result) :failed)))))) + (should-not (plist-get result :defs)) + (should (member 'wiktionary (plist-get result :failed)))))) (provide 'test-gloss-fetch--definitions-500-returns-server-error) ;;; test-gloss-fetch--definitions-500-returns-server-error.el ends here |
