diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-05 12:39:55 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-05 12:39:55 -0500 |
| commit | 3019a33d391912120a78cad43a49eb34c4a1d044 (patch) | |
| tree | 4941d154529ce988bbdeb5e1929fa6cdea35f94a /tests/test-chime-apply-whitelist.el | |
| parent | 26fabb22edfea51e8a686c179ab91d00a2ff0bc3 (diff) | |
| download | chime-3019a33d391912120a78cad43a49eb34c4a1d044.tar.gz chime-3019a33d391912120a78cad43a49eb34c4a1d044.zip | |
refactor!: collapse six filter defcustoms into include/exclude alists
Six per-axis filter variables (keyword/tags/predicate × whitelist/blacklist)
were carrying parallel structure for what's really one decision: include
events that look like X, exclude events that look like Y. I merged them
into two alists, `chime-include-filters' and `chime-exclude-filters', each
keyed by axis (`keywords', `tags', `predicates').
Default for `chime-exclude-filters' keeps the same out-of-the-box
behavior — done items and declined Google Calendar invites stay
filtered:
((predicates . (chime-done-keywords-predicate
chime-declined-events-predicate)))
Implementation: one shared `chime--filter-predicates' helper that walks
the alist and emits a marker-taking predicate per non-empty axis. The
public callers — now `chime--apply-include-filters' and
`chime--apply-exclude-filters' — wrap that helper with
`-orfn'-then-`-filter' and `-orfn'-then-`-remove' respectively. The
async-environment regex injection list shrank from six names to two,
and the debug config dump in chime-debug.el follows.
The terminology shift (whitelist/blacklist → include/exclude) drops
loaded language for descriptive intent. The internal helpers and the
public function names all moved together.
Tests: 700-ish lines across five test files (test-chime-apply-whitelist,
test-chime-apply-blacklist, test-chime-whitelist-blacklist-conflicts,
test-chime-environment-regex, test-chime-declined-events-predicate)
were rewritten to bind the new alists. The dedup-conflict tests still
exercise the same precedence rule (exclude wins on overlap). README's
filtering section was rewritten end-to-end with new examples.
Migration:
(setq chime-keyword-whitelist '("TODO"))
;; ->
(setq chime-include-filters '((keywords . ("TODO"))))
(setq chime-predicate-blacklist '(my-pred))
;; ->
(setq chime-exclude-filters '((predicates . (my-pred))))
This brings the consolidation pass to 37 -> 29 defcustoms, the target
from .ai/settings-consolidation.org.
Diffstat (limited to 'tests/test-chime-apply-whitelist.el')
| -rw-r--r-- | tests/test-chime-apply-whitelist.el | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/tests/test-chime-apply-whitelist.el b/tests/test-chime-apply-whitelist.el index e61f3c3..1552ee2 100644 --- a/tests/test-chime-apply-whitelist.el +++ b/tests/test-chime-apply-whitelist.el @@ -1,4 +1,4 @@ -;;; test-chime-apply-whitelist.el --- Tests for chime--apply-whitelist -*- lexical-binding: t; -*- +;;; test-chime-apply-whitelist.el --- Tests for chime--apply-include-filters -*- lexical-binding: t; -*- ;; Copyright (C) 2024-2026 Craig Jennings @@ -19,7 +19,7 @@ ;;; Commentary: -;; Unit tests for chime--apply-whitelist function. +;; Unit tests for chime--apply-include-filters function. ;; Tests use real org-mode buffers with real org syntax. ;; Tests cover normal cases, boundary cases, and error cases. @@ -36,16 +36,12 @@ "Setup function run before each test." (chime-create-test-base-dir) ;; Reset whitelist settings - (setq chime-keyword-whitelist nil) - (setq chime-tags-whitelist nil) - (setq chime-predicate-whitelist nil)) + (setq chime-include-filters nil)) (defun test-chime-apply-whitelist-teardown () "Teardown function run after each test." (chime-delete-test-base-dir) - (setq chime-keyword-whitelist nil) - (setq chime-tags-whitelist nil) - (setq chime-predicate-whitelist nil)) + (setq chime-include-filters nil)) ;;; Normal Cases @@ -53,10 +49,9 @@ "Test that nil whitelist returns all markers unchanged." (test-chime-apply-whitelist-setup) (unwind-protect - (let* ((chime-keyword-whitelist nil) - (chime-tags-whitelist nil) + (let* ((chime-include-filters nil) (markers (list (make-marker) (make-marker) (make-marker))) - (result (chime--apply-whitelist markers))) + (result (chime--apply-include-filters markers))) ;; Should return all markers when whitelist is nil (should (equal (length result) 3))) (test-chime-apply-whitelist-teardown))) @@ -76,8 +71,8 @@ (let ((marker2 (point-marker))) (forward-line 1) (let ((marker3 (point-marker)) - (chime-keyword-whitelist '("TODO"))) - (let ((result (chime--apply-whitelist (list marker1 marker2 marker3)))) + (chime-include-filters `((keywords . ,'("TODO"))))) + (let ((result (chime--apply-include-filters (list marker1 marker2 marker3)))) ;; Should only keep TODO markers (should (= (length result) 2)) (should (member marker1 result)) @@ -100,8 +95,8 @@ (let ((marker2 (point-marker))) (forward-line 1) (let ((marker3 (point-marker)) - (chime-tags-whitelist '("urgent"))) - (let ((result (chime--apply-whitelist (list marker1 marker2 marker3)))) + (chime-include-filters `((tags . ,'("urgent"))))) + (let ((result (chime--apply-include-filters (list marker1 marker2 marker3)))) ;; Should only keep markers with "urgent" tag (should (= (length result) 2)) (should (member marker1 result)) @@ -124,9 +119,8 @@ (let ((marker2 (point-marker))) (forward-line 1) (let ((marker3 (point-marker)) - (chime-keyword-whitelist '("TODO")) - (chime-tags-whitelist '("urgent"))) - (let ((result (chime--apply-whitelist (list marker1 marker2 marker3)))) + (chime-include-filters `((keywords . ,'("TODO")) (tags . ,'("urgent"))))) + (let ((result (chime--apply-include-filters (list marker1 marker2 marker3)))) ;; Should keep marker1 (TODO) and marker3 (urgent tag) (should (= (length result) 2)) (should (member marker1 result)) @@ -140,8 +134,8 @@ "Test that empty markers list returns empty." (test-chime-apply-whitelist-setup) (unwind-protect - (let ((chime-keyword-whitelist '("TODO")) - (result (chime--apply-whitelist '()))) + (let ((chime-include-filters `((keywords . ,'("TODO")))) + (result (chime--apply-include-filters '()))) (should (equal result '()))) (test-chime-apply-whitelist-teardown))) @@ -157,8 +151,8 @@ (let ((marker1 (point-marker))) (forward-line 1) (let ((marker2 (point-marker)) - (chime-keyword-whitelist '("TODO"))) - (let ((result (chime--apply-whitelist (list marker1 marker2)))) + (chime-include-filters `((keywords . ,'("TODO"))))) + (let ((result (chime--apply-include-filters (list marker1 marker2)))) (should (= (length result) 1)) (should (member marker1 result)))))) (test-chime-apply-whitelist-teardown))) @@ -175,8 +169,8 @@ (let ((marker1 (point-marker))) (forward-line 1) (let ((marker2 (point-marker)) - (chime-keyword-whitelist '("TODO"))) - (let ((result (chime--apply-whitelist (list marker1 marker2)))) + (chime-include-filters `((keywords . ,'("TODO"))))) + (let ((result (chime--apply-include-filters (list marker1 marker2)))) (should (equal result '())))))) (test-chime-apply-whitelist-teardown))) @@ -191,8 +185,8 @@ (insert "* Entry without TODO keyword\n") (goto-char (point-min)) (let ((marker1 (point-marker)) - (chime-keyword-whitelist '("TODO"))) - (let ((result (chime--apply-whitelist (list marker1)))) + (chime-include-filters `((keywords . ,'("TODO"))))) + (let ((result (chime--apply-include-filters (list marker1)))) ;; Should filter out marker with nil keyword (not in whitelist) (should (= (length result) 0))))) (test-chime-apply-whitelist-teardown))) @@ -206,8 +200,8 @@ (insert "* Entry without tags\n") (goto-char (point-min)) (let ((marker1 (point-marker)) - (chime-tags-whitelist '("urgent"))) - (let ((result (chime--apply-whitelist (list marker1)))) + (chime-include-filters `((tags . ,'("urgent"))))) + (let ((result (chime--apply-include-filters (list marker1)))) ;; Should filter out marker with nil tags (not in whitelist) (should (= (length result) 0))))) (test-chime-apply-whitelist-teardown))) |
