blob: 6cc6cfc09efea9df2748e69b671c736f2fdddbed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
;;; test-gloss-core--corrupt-file-preserves-cache.el --- Tests for corrupt-file resilience -*- lexical-binding: t -*-
;; SPDX-License-Identifier: GPL-3.0-or-later
;;; Commentary:
;; Tests that a parser failure during cache reload does not destroy the
;; existing cache; previously-cached lookups still succeed and the user
;; sees an informative message.
;;; Code:
(require 'cl-lib)
(require 'ert)
(require 'gloss-core)
(require 'testutil-gloss)
(ert-deftest test-gloss-core-corrupt-file-preserves-existing-cache ()
"Error: parser failure during reload preserves the existing cache."
(gloss-test--with-temp-glossary gloss-test--sample-content
;; Prime cache.
(should (gloss-core-lookup "anaphora"))
;; Force mtime change to trigger a reload attempt.
(set-file-times gloss-file (time-add (current-time) 5))
;; Mock the parse helper to fail.
(cl-letf (((symbol-function 'gloss-core--parse-file-into-cache)
(lambda () (error "simulated parse failure"))))
(let ((inhibit-message t))
;; Lookup must not propagate the error; cached entry remains findable.
(should (gloss-core-lookup "anaphora"))))))
(provide 'test-gloss-core--corrupt-file-preserves-cache)
;;; test-gloss-core--corrupt-file-preserves-cache.el ends here
|