aboutsummaryrefslogtreecommitdiff
path: root/tests/test-chime-environment-regex.el
blob: 2499ad06db7d0adc4d9a245759292cb2c2c82fff (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
;;; test-chime-environment-regex.el --- Tests for chime-environment-regex -*- lexical-binding: t; -*-

;; Copyright (C) 2026 Craig Jennings

;; Author: Craig Jennings <c@cjennings.net>

;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; Unit tests for chime-environment-regex function.
;; This function generates the regex used by async-inject-variables to
;; copy chime's config into the async subprocess.

;;; Code:

(require 'test-bootstrap (expand-file-name "test-bootstrap.el"))

;;; Normal Cases

(ert-deftest test-chime-environment-regex-matches-default-variables ()
  "The generated regex should match all default chime variable names."
  (let ((regex (chime-environment-regex))
        (chime-additional-environment-regexes nil))
    (dolist (var '("org-agenda-files" "load-path" "org-todo-keywords"
                   "chime-alert-intervals" "chime-keyword-whitelist"
                   "chime-keyword-blacklist" "chime-tags-whitelist"
                   "chime-tags-blacklist" "chime-predicate-whitelist"
                   "chime-predicate-blacklist"))
      (should (string-match-p regex var)))))

(ert-deftest test-chime-environment-regex-includes-additional-regexes ()
  "With additional regexes configured, the result should match those too."
  (let ((chime-additional-environment-regexes '("my-custom-var")))
    (let ((regex (chime-environment-regex)))
      ;; Should still match defaults
      (should (string-match-p regex "org-agenda-files"))
      ;; Should also match the custom variable
      (should (string-match-p regex "my-custom-var")))))

;;; Boundary Cases

(ert-deftest test-chime-environment-regex-empty-additional-list ()
  "Empty additional regexes list should produce a valid regex matching defaults."
  (let ((chime-additional-environment-regexes nil))
    (let ((regex (chime-environment-regex)))
      (should (stringp regex))
      (should (string-match-p regex "chime-alert-intervals")))))

(provide 'test-chime-environment-regex)
;;; test-chime-environment-regex.el ends here