summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2021-02-07 02:57:34 -0500
committerKyle Meyer <kyle@kyleam.com>2021-02-07 12:38:50 -0500
commite06a50377649da9af7a804ba225b400c87e11d40 (patch)
tree9c402d4410bcfd78bba12179ddd90dba5121e74b /tests
parent0a3de9e528c010e3f8ff113eaca28f10ad0528ca (diff)
downloadpiem-e06a50377649da9af7a804ba225b400c87e11d40.tar.gz
piem: Add helper to construct message ID link
There are two spots that use (piem-inbox-get :url ...) and piem-escape-mid to construct the public-inbox link, and there is about to be another. Extract this shared logic. Cc: Xinglu Chen <public@yoctocell.xyz> Message-Id: <20210207075738.8752-2-kyle@kyleam.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/piem-tests.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/piem-tests.el b/tests/piem-tests.el
index 795686a..969c9d0 100644
--- a/tests/piem-tests.el
+++ b/tests/piem-tests.el
@@ -49,6 +49,19 @@
(should (equal (piem-escape-mid "msg@id") "msg@id"))
(should (equal (piem-escape-mid "m/g@id") "m%2Fg@id")))
+(ert-deftest piem-mid-url ()
+ (let ((piem-inboxes '(("inbox-a" :url "https://example.com/a/")
+ ("inbox-b" :url "https://example.com/b/"))))
+ (should (equal (piem-mid-url "msg@id" "inbox-a")
+ "https://example.com/a/msg@id"))
+ (should (equal (piem-mid-url "m/sg@id" "inbox-b")
+ "https://example.com/b/m%2Fsg@id"))
+ (should-error (piem-mid-url "msg@id")
+ :type 'user-error))
+ (let ((piem-inboxes '(("inbox-a"))))
+ (should-error (piem-mid-url "msg@id" "inbox-a")
+ :type 'user-error)))
+
(ert-deftest piem-name-branch-who-what-v ()
(should (equal (piem-name-branch-who-what-v
(list :from "Foo Bar <f@example.com>"