aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2021-05-27 19:27:14 -0400
committerKyle Meyer <kyle@kyleam.com>2021-05-27 22:34:20 -0400
commit205f45561c2f19b17b11a5c0168568ecceae4008 (patch)
treea6af219f1f0d84d61f0b0a9357f92a9bd1830691 /tests
parentc99e806fd307ef69adc0d3a277385687edfd3454 (diff)
downloadpiem-205f45561c2f19b17b11a5c0168568ecceae4008.tar.gz
Add basic integration for Rmail
Teach piem how to get the associated inbox and message ID for the current Rmail message. Message-Id: <20210527232714.8726-1-kyle@kyleam.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/piem-rmail-tests.el73
-rw-r--r--tests/piem-tests.el1
2 files changed, 74 insertions, 0 deletions
diff --git a/tests/piem-rmail-tests.el b/tests/piem-rmail-tests.el
new file mode 100644
index 0000000..b489594
--- /dev/null
+++ b/tests/piem-rmail-tests.el
@@ -0,0 +1,73 @@
+;;; piem-rmail-tests.el --- tests for piem-rmail -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2021 all contributors <piem@inbox.kyleam.com>
+
+;; Author: Kyle Meyer <kyle@kyleam.com>
+
+;; 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 <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+(require 'piem-rmail)
+
+(defvar piem-rmail-tests-mbox-text "\
+From mboxrd@z Thu Jan 1 00:00:00 1970
+From: A <a@example.com>
+To: i@inbox.example.com
+Subject: test
+Date: Sun, 23 May 2021 02:26:01 -0400
+Message-ID: <123@example.com>
+
+test body
+
+From mboxrd@z Thu Jan 1 00:00:00 1970
+From: b <b@example.com>
+To: A <a@example.com>
+Cc: i@inbox.example.com
+Subject: Re: test
+Date: Sun, 23 May 2021 02:26:51 -0400
+Message-Id: <456@example.com>
+In-Reply-To: <123@example.com>
+References: <123@example.com>
+
+> test body
+
+no thanks
+")
+
+(ert-deftest piem-rmail-get-inbox ()
+ (should
+ (equal "foo"
+ (with-temp-buffer
+ (insert piem-rmail-tests-mbox-text)
+ (rmail-mode)
+ (let ((piem-inboxes '(("foo" :address "i@inbox.example.com"))))
+ (piem-rmail-get-inbox))))))
+
+(ert-deftest piem-rmail-get-mid ()
+ (should
+ (equal (list "123@example.com" "456@example.com")
+ (with-temp-buffer
+ (insert piem-rmail-tests-mbox-text)
+ (rmail-mode)
+ (rmail-first-message)
+ (let ((piem-inboxes '(("foo" :address "i@inbox.example.com"))))
+ (list (piem-rmail-get-mid)
+ (progn
+ (rmail-next-message 1)
+ (piem-rmail-get-mid))))))))
+
+(provide 'piem-rmail-tests)
+;;; piem-rmail-tests.el ends here
diff --git a/tests/piem-tests.el b/tests/piem-tests.el
index 969c9d0..5f01a5e 100644
--- a/tests/piem-tests.el
+++ b/tests/piem-tests.el
@@ -21,6 +21,7 @@
(require 'ert)
(require 'piem)
+(require 'piem-rmail-tests)
(ert-deftest piem-message-link-re ()
(should-not (string-match-p