From 2bf9c383b2943eef1754e20db24419f8e269a8b7 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Thu, 5 May 2022 21:40:17 -0400 Subject: piem-inboxes: Support mapping inbox to multiple coderepos An inbox may regularly receive patches for multiple repos. Allow an inbox's :coderepo to be a list, and teach piem-inbox-coderepo to select a target repo by prompting the caller with the configured list. Message-Id: <20220506014017.14259-1-kyle@kyleam.com> --- tests/piem-tests.el | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests') diff --git a/tests/piem-tests.el b/tests/piem-tests.el index 444ed5f..79d8591 100644 --- a/tests/piem-tests.el +++ b/tests/piem-tests.el @@ -49,6 +49,21 @@ dir = /code/foo/.git ") +(defvar piem-tests-sample-pi-config-multiple-coderepos " +[publicinbox \"foo\"] + address = foo@example.com + url = https://example.com/foo + inboxdir = /inboxes/foo + coderepo = foo.git + coderepo = bar.git + +[coderepo \"foo.git\"] + dir = /code/foo/.git + +[coderepo \"bar.git\"] + dir = /code/bar/.git +") + (ert-deftest piem-merged-inboxes:from-config-disabled () (let ((piem-get-inboxes-from-config nil) (piem-inboxes nil)) @@ -78,6 +93,20 @@ (piem-clear-merged-inboxes) (should-not (piem-inbox-get :address "foo"))))) +(ert-deftest piem-merged-inboxes:from-config-multiple-coderepos () + (piem-clear-merged-inboxes) + (let ((piem-get-inboxes-from-config t) + (piem-inboxes nil)) + (piem-tests-with-pi-config piem-tests-sample-pi-config-multiple-coderepos + (cl-letf (((symbol-function 'completing-read) + (lambda (&rest _) "/code/foo"))) + (should (equal (piem-inbox-coderepo "foo") + "/code/foo/"))) + (cl-letf (((symbol-function 'completing-read) + (lambda (&rest _) "/code/bar"))) + (should (equal (piem-inbox-coderepo "foo") + "/code/bar/")))))) + (ert-deftest piem-merged-inboxes:override-config () (piem-clear-merged-inboxes) (let ((piem-get-inboxes-from-config t) -- cgit v1.2.3