1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-07 15:00:34 -08:00
emacs/test/lisp/erc/erc-scenarios-base-association-query.el
F. Jason Park f04680e067 Fix some naming issues involving query buffers in ERC
* lisp/erc/erc-networks.el
(erc-networks-rename-surviving-target-buffer): Don't kill a surviving
target buffer when another, non-target buffer, possibly not even
belonging to ERC, already exists and sports the target's name.
(erc-networks--reconcile-buffer-names): Always append a network-ID
suffix to a target buffer's name if another buffer of that name
already exists.  (Bug#59976.)
* lisp/erc/erc.el (erc, erc-tls): Revise `:id' portion of doc strings.
Thanks to Mike Kazantsev for the suggestion and for filing this bug
and helping solve it.
* test/lisp/erc/erc-networks-tests.el:
(erc-networks-rename-surviving-target-buffer--query-non-target): Add
new test.
* test/lisp/erc/erc-scenarios-base-association-query.el: New file.
* test/lisp/erc/resources/base/assoc/queries/netnick.eld: New file.
* test/lisp/erc/resources/base/assoc/queries/non-erc.eld: New file.
2022-12-16 06:36:24 -08:00

107 lines
4.2 KiB
EmacsLisp

;;; erc-scenarios-base-association-query.el --- assoc query scenarios -*- lexical-binding: t -*-
;; Copyright (C) 2022 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
;; GNU Emacs 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.
;; GNU Emacs 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/>.
;;; Code:
(require 'ert-x)
(eval-and-compile
(let ((load-path (cons (ert-resource-directory) load-path)))
(require 'erc-scenarios-common)))
(eval-when-compile (require 'erc-join))
;; Non-ERC buffers exist whose names match the nicknames of query
;; targets, both newly arriving and outgoing. No target buffers yet
;; exist for these, so new ones are created that feature a net-ID
;; @suffix.
(ert-deftest erc-scenarios-base-association-existing-non-erc-buffer ()
:tags '(:expensive-test)
(erc-scenarios-common-with-cleanup
((erc-scenarios-common-dialog "base/assoc/queries")
(dumb-server (erc-d-run "localhost" t 'non-erc))
(port (process-contact dumb-server :service))
(expect (erc-d-t-make-expecter))
(nitwit (with-current-buffer (get-buffer-create "nitwit")
(prin1 (ert-test-name (ert-running-test)) (current-buffer))
(current-buffer))) ; these are killed on completion by macro
(dummy (with-current-buffer (get-buffer-create "dummy")
(prin1 (ert-test-name (ert-running-test)) (current-buffer))
(current-buffer)))
(erc-server-flood-penalty 0.1))
(ert-info ("Connect to foonet")
(with-current-buffer (erc :server "127.0.0.1"
:port port
:nick "tester"
:user "tester"
:full-name "tester")
(erc-scenarios-common-assert-initial-buf-name nil port)
(erc-d-t-wait-for 5 (eq erc-network 'foonet))
(funcall expect 15 "debug mode")))
(ert-info ("Nick dummy queries us")
(with-current-buffer (erc-d-t-wait-for 10 (get-buffer "dummy@foonet"))
(should (erc-query-buffer-p))
(funcall expect 5 "hi")
(ert-info ("We query nick nitwit")
(with-current-buffer (erc-cmd-QUERY "nitwit")
(should (equal (buffer-name) "nitwit@foonet"))
(erc-scenarios-common-say "hola")
(funcall expect 5 "ciao")))
(erc-scenarios-common-say "howdy")
(funcall expect 5 "bye")
(erc-cmd-QUIT "")))))
;; Someone sending you a PM has the same name as the network (bug#59976)
(ert-deftest erc-scenarios-base-association-some-nick-is-network ()
:tags '(:expensive-test)
(erc-scenarios-common-with-cleanup
((erc-scenarios-common-dialog "base/assoc/queries")
(dumb-server (erc-d-run "localhost" t 'netnick))
(port (process-contact dumb-server :service))
(expect (erc-d-t-make-expecter))
(erc-server-flood-penalty 0.5))
(ert-info ("Connect to foonet")
(with-current-buffer (erc :server "127.0.0.1"
:port port
:nick "tester"
:user "tester"
:full-name "tester")
(erc-scenarios-common-assert-initial-buf-name nil port)
(erc-d-t-wait-for 5 (eq erc-network 'foonet))))
(ert-info ("Join common channel as nick foonet")
(with-current-buffer "foonet"
(funcall expect 15 "debug mode")
(erc-cmd-JOIN "#chan"))
(with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan"))
(funcall expect 5 "welcome")))
(ert-info ("Nick foonet PMs us")
(with-current-buffer (erc-d-t-wait-for 10 (get-buffer "foonet@foonet"))
(should (erc-query-buffer-p))
(funcall expect 5 "hi")))))
;;; erc-scenarios-base-association-query.el ends here