aboutsummaryrefslogtreecommitdiff
path: root/tests/test-gloss-drill--export-all-no-orgdrill-installed.el
blob: f8f496758e1674d3ae6add99069c5a56040c704d (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
33
34
35
36
37
38
;;; test-gloss-drill--export-all-no-orgdrill-installed.el --- Error tests for missing org-drill -*- lexical-binding: t -*-

;; SPDX-License-Identifier: GPL-3.0-or-later

;;; Commentary:
;; Tests for `gloss-drill-export-all' covering the Error case where
;; `org-drill' is not installed.  The function must raise `user-error'
;; with an install hint and must not touch `gloss-file'.

;;; Code:

(require 'ert)
(require 'gloss-drill)
(require 'testutil-gloss)
(require 'testutil-gloss-drill)

(ert-deftest test-gloss-drill-export-all-without-org-drill-raises-user-error ()
  "Error: missing `org-drill' raises `user-error' with an install hint."
  (gloss-test--with-temp-glossary gloss-test--sample-content
    (gloss-test--without-org-drill-feature
      (let ((err (should-error (gloss-drill-export-all) :type 'user-error)))
        (should (string-match-p "org-drill" (error-message-string err)))))))

(ert-deftest test-gloss-drill-export-all-without-org-drill-leaves-file-untouched ()
  "Error: missing `org-drill' must not modify the glossary file."
  (gloss-test--with-temp-glossary gloss-test--sample-content
    (gloss-test--without-org-drill-feature
      (let ((before (with-temp-buffer
                      (insert-file-contents gloss-file)
                      (buffer-string))))
        (ignore-errors (gloss-drill-export-all))
        (let ((after (with-temp-buffer
                       (insert-file-contents gloss-file)
                       (buffer-string))))
          (should (equal before after)))))))

(provide 'test-gloss-drill--export-all-no-orgdrill-installed)
;;; test-gloss-drill--export-all-no-orgdrill-installed.el ends here