From 37742c886f4ab15b1d74331f399a0ca3d6412901 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sun, 10 May 2020 13:25:56 +0200 Subject: debbugs: Add bug-id->summary-file. * mumi/debbugs.scm (bug-id->summary-file): New procedure. * tests/debbugs.scm: New file. * tests/data/spool/archive/95/26095.{report,status,summary}: New files. * Makefile.am (SCM_TESTS): Add tests/debbugs.scm. (EXTRA_DIST): Include test data. --- tests/debbugs.scm | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/debbugs.scm (limited to 'tests/debbugs.scm') diff --git a/tests/debbugs.scm b/tests/debbugs.scm new file mode 100644 index 0000000..6631b9f --- /dev/null +++ b/tests/debbugs.scm @@ -0,0 +1,46 @@ +;;; mumi -- Mediocre, uh, mail interface +;;; Copyright © 2020 Ricardo Wurmus +;;; +;;; This program is free software: you can redistribute it and/or +;;; modify it under the terms of the GNU Affero 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 +;;; Affero General Public License for more details. +;;; +;;; You should have received a copy of the GNU Affero General Public +;;; License along with this program. If not, see +;;; . + +(define-module (test-debbugs) + #:use-module (mumi config) + #:use-module (mumi debbugs) + #:use-module (ice-9 match) + #:use-module (srfi srfi-64)) + +(define-syntax-rule (mock (module proc replacement) body ...) + "Within BODY, replace the definition of PROC from MODULE with the definition +given by REPLACEMENT." + (let* ((m (resolve-module 'module)) + (original (module-ref m 'proc))) + (dynamic-wind + (lambda () (module-set! m 'proc replacement)) + (lambda () body ...) + (lambda () (module-set! m 'proc original))))) + +(test-begin "debbugs") + +(define data-dir + (string-append (getenv "abs_top_srcdir") "/tests/data")) + +(test-equal "bug-id->summary-file: return archive summary file" + (format #f "~a/spool/archive/95/26095.summary" data-dir) + (mock ((mumi config) %config + (match-lambda + ('data-dir data-dir))) + ((@@ (mumi debbugs) bug-id->summary-file) 26095))) + +(test-end "debbugs") -- cgit v1.2.3