all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 78b75a530c0db060be8f389b069b944a6880d1f2 4351 bytes (raw)
name: test/lisp/erc/erc-scenarios-base-association-query.el 	 # note: path name is non-authoritative(*)

  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
 
;;; 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

debug log:

solving 78b75a530c ...
found 78b75a530c in https://git.savannah.gnu.org/cgit/emacs.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.