aboutsummaryrefslogtreecommitdiff
path: root/tests/test-mu4e-attachments.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-12 00:35:20 -0500
committerCraig Jennings <c@cjennings.net>2026-05-12 00:35:20 -0500
commit203560396ea67bac7a7375cd2fbfa99433b672a9 (patch)
treea219da5fe486f854883ac998c3cd67268324db86 /tests/test-mu4e-attachments.el
parent22232fc39598ffc065ee134889c3143566be5faa (diff)
downloaddotemacs-203560396ea67bac7a7375cd2fbfa99433b672a9.tar.gz
dotemacs-203560396ea67bac7a7375cd2fbfa99433b672a9.zip
refactor(mail): fail fast on an attachment part with no MIME handle
`cj/mu4e--save-attachment-part' called `cj/mu4e--ensure-attachment-save-functions' first, so a part with no MIME handle triggered the `mu4e-mime-parts' load before the handle check could fail. The handle check now runs first, so the malformed input is caught right away and the user-error fires the same way whether or not mu4e's MIME support is loadable. The test for that case drops the mu4e stubs it only needed because the load used to come first.
Diffstat (limited to 'tests/test-mu4e-attachments.el')
-rw-r--r--tests/test-mu4e-attachments.el12
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/test-mu4e-attachments.el b/tests/test-mu4e-attachments.el
index 86a42916..3105d710 100644
--- a/tests/test-mu4e-attachments.el
+++ b/tests/test-mu4e-attachments.el
@@ -67,13 +67,13 @@
(should (equal saved '("handle" "/downloads/invoice.pdf.unique"))))))
(ert-deftest test-mu4e-attachments-save-part-errors-without-handle ()
- "Error: a malformed part without a MIME handle fails clearly."
- (let ((part (test-mu4e-attachments--part "invoice.pdf" 3 nil))
- (mu4e-uniquify-save-file-name-function #'identity))
+ "Error: a malformed part without a MIME handle fails clearly.
+The handle check runs before `cj/mu4e--ensure-attachment-save-functions',
+so this fails the same way whether or not mu4e's MIME support is loadable."
+ (let ((part (test-mu4e-attachments--part "invoice.pdf" 3 nil)))
(setq part (plist-put part :handle nil))
- (cl-letf (((symbol-function 'mu4e-join-paths) #'list))
- (should-error (cj/mu4e--save-attachment-part part "/downloads")
- :type 'user-error))))
+ (should-error (cj/mu4e--save-attachment-part part "/downloads")
+ :type 'user-error)))
(ert-deftest test-mu4e-attachments-save-all-prompts-once ()
"Normal: the save-all command prompts for a directory once and saves all parts."