GNU bug report logs -
#72574
[PATCH 0/3] debbugs improvements. Add tests
Previous Next
Full log
Message #14 received at 72574 <at> debbugs.gnu.org (full text, mbox):
* Makefile: New file.
* test/test-debbugs.el: New file.
---
Makefile | 4 ++
test/test-debbugs.el | 101 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 105 insertions(+)
create mode 100644 Makefile
create mode 100644 test/test-debbugs.el
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000..3a4b06a76e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+.PHONY: check
+
+check:
+ emacs -Q --batch -L . -l test/* -f ert-run-tests-batch-and-exit
diff --git a/test/test-debbugs.el b/test/test-debbugs.el
new file mode 100644
index 0000000000..8eca3fe3a8
--- /dev/null
+++ b/test/test-debbugs.el
@@ -0,0 +1,101 @@
+;;; test-debbugs.el --- tests for debbugs.el -*- lexical-binding: t; -*-
+
+;;; Commentary:
+
+;; Please ensure tests don't actually make network calls.
+
+;;; Code:
+
+(require 'debbugs)
+
+;;; Helper Data:
+
+;; Generated using this:
+;; (soap-invoke debbugs-wsdl debbugs-port "get_status" [64064])
+(defvar test-bug-status-soap-return
+ '(((item (key . 64064)
+ (value (package . "emacs") (found_date) (last_modified . 1689593050)
+ (affects) (date . 1686745022) (fixed_versions)
+ (originator . "Morgan Smith <Morgan.J.Smith <at> outlook.com>")
+ (blocks) (archived . 1) (found) (unarchived) (tags . "patch")
+ (severity . "normal") (location . "archive") (owner) (fixed)
+ (blockedby) (pending . "done") (keywords . "patch") (id . 64064)
+ (found_versions) (mergedwith) (summary) (forwarded)
+ (log_modified . 1689593050)
+ (done . "Michael Albinus <michael.albinus <at> gmx.de>")
+ (source . "unknown")
+ (msgid
+ . "<DM5PR03MB31632E3A4FE170C62E7D4B0CC55AA <at> DM5PR03MB3163.namprd03.prod.outlook.com>")
+ (bug_num . 64064) (subject . "[PATCH 0/4] debbugs improvements")
+ (fixed_date))))))
+
+;; Generated using this:
+;; (debbugs-get-status 64064)
+(defvar test-bug-status
+ '(((cache_time . 5000) (source . "unknown") (unarchived)
+ (keywords "patch") (blocks) (pending . "done") (severity . "normal") (found)
+ (done . "Michael Albinus <michael.albinus <at> gmx.de>") (location . "archive")
+ (log_modified . 1689593050) (subject . "[PATCH 0/4] debbugs improvements")
+ (last_modified . 1689593050)
+ (originator . "Morgan Smith <Morgan.J.Smith <at> outlook.com>") (archived . t)
+ (blockedby) (affects) (mergedwith) (summary) (date . 1686745022)
+ (fixed_versions) (id . 64064) (fixed) (found_date) (forwarded) (tags "patch")
+ (msgid
+ . "<DM5PR03MB31632E3A4FE170C62E7D4B0CC55AA <at> DM5PR03MB3163.namprd03.prod.outlook.com>")
+ (owner) (found_versions) (fixed_date) (bug_num . 64064) (package "emacs"))))
+
+;;; Helper Functions:
+
+(defvar test-soap-operation-name nil)
+(defvar test-soap-parameters nil)
+(defun soap-invoke-internal (callback _cbargs _wsdl _service operation-name &rest parameters)
+ "Over-ride for testing"
+ (setq test-soap-operation-name operation-name)
+ (setq test-soap-parameters parameters)
+ (let ((return
+ (cond ((string-equal operation-name "get_status") test-bug-status-soap-return)
+ ((string-equal operation-name "get_usertag") '(((hi))))
+ (t '((0))))))
+ (if callback
+ (progn
+ (funcall callback return)
+ nil)
+ return)))
+
+;;; Tests:
+
+(ert-deftest test-debbugs-get-bugs ()
+ (let (test-soap-operation-name test-soap-parameters)
+ (debbugs-get-bugs
+ :tag "patch"
+ :severity "critical"
+ :status "open"
+ :status "forwarded")
+ (should (string-equal test-soap-operation-name "get_bugs"))
+ (should (equal test-soap-parameters '(["tag" "patch" "severity" "critical"
+ "status" "open" "status" "forwarded"])))))
+
+(ert-deftest test-debbugs-newest-bugs ()
+ (let (test-soap-operation-name test-soap-parameters)
+ (debbugs-newest-bugs 4)
+ (should (string-equal test-soap-operation-name "newest_bugs"))
+ (should (equal test-soap-parameters '(4)))))
+
+(ert-deftest test-debbugs-get-status ()
+ (let ((original-float-time (symbol-function 'float-time))
+ test-soap-operation-name test-soap-parameters)
+ (fset 'float-time (lambda (&optional _specified-time) 5000))
+ (should (= (float-time) 5000))
+ (should (equal (sort (car (debbugs-get-status 64064))) (sort (car test-bug-status))))
+ (should (string-equal test-soap-operation-name "get_status"))
+ (should (equal test-soap-parameters '([64064])))
+ (fset 'float-time original-float-time)))
+
+(ert-deftest test-debbugs-get-usertag ()
+ (let (test-soap-operation-name test-soap-parameters)
+ (should (equal (debbugs-get-usertag :user "emacs") '("hi")))
+ (should (string-equal test-soap-operation-name "get_usertag"))
+ (should (equal test-soap-parameters '("emacs")))))
+
+(provide 'test-debbugs)
+;;; test-debbugs.el ends here
--
2.45.2
This bug report was last modified 343 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.