Subject: Re: bug#76446: 0002-tests-Add-tests-for-debbugs-gnu.patch

From: Morgan Smith <[email-masked]>
Date: Fri, 21 Feb 2025 13:11:51 -0500

Michael Albinus <[email-masked]> writes:

> Morgan Smith <[email-masked]> writes:
>
>> --- /dev/null
>> +++ b/test/debbugs-gnu-tests.el
>> +(require 'debbugs)
>> +(require 'debbugs-gnu)
>> +(require 'debbugs-test-helpers "./test/debbugs-test-helpers")
>
> (require 'debbugs-test-helpers) is sufficient.
>

Done!

>> +(ert-deftest--debbugs debbugs-test-debbugs-gnu-search ()
>> +  "Test `debbugs-gnu-search'.
>
> Isn't it rather a test of `debbugs-gnu'?
>

Nope! The intention is to test `debbugs-gnu-search'.  In fact I stub out
`debbugs-gnu' with #'list so that I can test how `debbugs-gnu is
being calling by `debbugs-gnu-search''.

>> +Also test `debbugs-gnu-patches' and `debbugs-gnu-tagged' which are
>> +simple wrappers for `debbugs-gnu-search'."
>
> Nope. They are wrappers of `debbugs-gnu'.

Oops!  You're right.  I have removed those tests.

> Best regards, Michael.

>From 3bd34242bffce78a908ca66ff1073e304d185fda Mon Sep 17 00:00:00 2001
From: Morgan Smith <[email-masked]>
Date: Fri, 21 Feb 2025 12:52:24 -0500
Subject: [PATCH v2 3/5] tests: Add tests for debbugs-gnu

* test/debbugs-gnu-tests.el: New file.
---
 test/debbugs-gnu-tests.el | 47 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 test/debbugs-gnu-tests.el

diff --git a/test/debbugs-gnu-tests.el b/test/debbugs-gnu-tests.el
new file mode 100644
index 0000000000..04c445e43b
--- /dev/null
+++ b/test/debbugs-gnu-tests.el
@@ -0,0 +1,47 @@
+;;; debbugs-gnu-tests.el --- tests for debbugs-gnu.el -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2025 Free Software Foundation, Inc.
+
+;; Author: Morgan Smith <[email-masked]>
+;; Package: debbugs
+
+;; This file is not part of GNU Emacs.
+
+;; 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 GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Please ensure tests don't actually make network calls.
+
+;;; Code:
+
+(require 'debbugs)
+(require 'debbugs-gnu)
+(require 'debbugs-test-helpers)
+
+;;; Tests:
+
+(ert-deftest--debbugs debbugs-test-debbugs-gnu-search ()
+  "Test `debbugs-gnu-search'."
+  (cl-letf (((symbol-function #'debbugs-gnu)
+             #'list))
+    (should
+     (equal '(nil ("guix" "guix-patches") nil)
+            (debbugs-gnu-search "frogs" '((pending . "pending")) nil '("guix" "guix-patches") nil)))
+    (should (equal debbugs-gnu-current-query '((phrase . "frogs"))))
+    (should (equal debbugs-gnu-current-filter '((pending . "pending"))))))
+
+(provide 'debbugs-gnu-tests)
+
+;;; debbugs-gnu-tests.el ends here
-- 
2.48.1