discussion and development of piem
 help / color / mirror / code / Atom feed
5f01a5e9f3f71cf886864ab95408bff572335d16 blob 4407 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
 
;;; piem-tests.el --- tests for piem                 -*- 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)
(require 'piem-rmail-tests)

(ert-deftest piem-message-link-re ()
  (should-not (string-match-p
               (piem-message-link-re "https://example.com/inbox")
               "https://example.com/inbox"))
  (should (string-match-p
           (piem-message-link-re "https://example.com/inbox")
           "https://example.com/inbox/msg@id/"))
  (should-not (string-match-p
               (piem-message-link-re "https://example.com/inbox" "msg@id1")
               "https://example.com/inbox/msg@id/"))
  (should (string-match-p
           (piem-message-link-re "https://example.com/inbox/")
           "https://example.com/inbox/msg@id/T/#t"))
  (should (string-match-p
           (piem-message-link-re "https://example.com/inbox/")
           "https://example.com/inbox/msg@id/T/#r53974723fd9"))
  (should (string-match-p
           (piem-message-link-re "https://example.com/inbox/")
           "https://example.com/inbox/msg@id/T/#r53974723fd9"))
  (should (string-match-p
           (piem-message-link-re "https://example.com/inbox/")
           "https://example.com/inbox/msg@id/t/#ma0d6f35c094")))

(ert-deftest piem-escape-mid ()
  (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>"
                        :subject "[PATCH] Do a thing"))
                 "fb/do-thing"))
  (should (equal (piem-name-branch-who-what-v
                  (list :from "Foo <f@example.com>"
                        :subject "[PATCH] Do a thing"))
                 "f/do-thing"))
  (should (equal (piem-name-branch-who-what-v
                  (list :from "Foo Bar <f@example.com>"
                        :subject "[PATCH v3] Do a thing"))
                 "fb/do-thing__v3"))
  (should-not (piem-name-branch-who-what-v
               (list :from "Foo Bar <xyz.com>"))))

(ert-deftest piem--insert-message-id-header ()
  (should-not
   (with-temp-buffer
     (piem--insert-message-id-header "msg@id")))
  (should
   (string-match-p
    (concat
     (rx "Subject: [PATCH 1/2] a\nMessage-Id: <msg@id>\n"
         (one-or-more anychar)
         "Subject: [PATCH 2/2] b\nMessage-Id: <msg@id>\n"))
    (with-temp-buffer
      (insert "\
From 0d732713af1f3fb48b37430e2cd0a3033cea14f3 Mon Sep 17 00:00:00 2001
From: Foo Bar <f@example.com>
Date: Fri, 22 Jan 2021 22:35:58 -0500
Subject: [PATCH 1/2] a

---
 a | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 a

From 7b2433ead6d8d10bff3325cb3719a316ddb52392 Mon Sep 17 00:00:00 2001
From: Foo Bar <f@example.com>
Date: Fri, 22 Jan 2021 22:36:09 -0500
Subject: [PATCH 2/2] b

---
 b | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 b")
      (goto-char (point-min))
      (piem--insert-message-id-header "msg@id")
      (buffer-string)))))

(provide 'piem-tests)
;;; piem-tests.el ends here
debug log:

solving 5f01a5e ...
found 5f01a5e in https://git.kyleam.com/piem/

discussion and development of piem

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.kyleam.com/piem/0 piem/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 piem piem/ https://inbox.kyleam.com/piem \
		piem@inbox.kyleam.com
	public-inbox-index piem

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.piem


code repositories for project(s) associated with this inbox:

	https://git.kyleam.com/piem/

AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git