From 1a788069b757c823012fc1135511a7af4b026437 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 4 Apr 2026 15:30:30 -0500 Subject: Add tests for chime-environment-regex Verify the regex matches all default variable names, picks up additional user-configured regexes, and handles empty additional list. --- tests/test-chime-environment-regex.el | 62 +++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tests/test-chime-environment-regex.el (limited to 'tests') diff --git a/tests/test-chime-environment-regex.el b/tests/test-chime-environment-regex.el new file mode 100644 index 0000000..2499ad0 --- /dev/null +++ b/tests/test-chime-environment-regex.el @@ -0,0 +1,62 @@ +;;; test-chime-environment-regex.el --- Tests for chime-environment-regex -*- lexical-binding: t; -*- + +;; Copyright (C) 2026 Craig Jennings + +;; Author: Craig Jennings + +;; 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 . + +;;; 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 -- cgit v1.2.3