From e06a50377649da9af7a804ba225b400c87e11d40 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 7 Feb 2021 02:57:34 -0500 Subject: 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 Message-Id: <20210207075738.8752-2-kyle@kyleam.com> --- tests/piem-tests.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') 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 " -- cgit v1.2.3