emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/plz b6072edeec 2/2: Tests: Use both HTTP/1.1 and HTTP/2


From: ELPA Syncer
Subject: [elpa] externals/plz b6072edeec 2/2: Tests: Use both HTTP/1.1 and HTTP/2
Date: Sat, 31 Dec 2022 17:57:58 -0500 (EST)

branch: externals/plz
commit b6072edeec1f0e2465d273db74a8f2f7726e6bce
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Tests: Use both HTTP/1.1 and HTTP/2
    
    As before, when run with ERT, the results are inconsistent, yet the
    library seems to work fine in practice.
---
 README.org        |  3 ++-
 plz.info          | 19 ++++++++--------
 tests/test-plz.el | 65 ++++++++++++++++++++++++++++++++++---------------------
 3 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/README.org b/README.org
index 85d6d58f98..1c0370f769 100644
--- a/README.org
+++ b/README.org
@@ -175,7 +175,8 @@ You may also clear a queue with ~plz-clear~, which cancels 
any active or queued
 
 ** 0.4-pre
 
-Nothing new yet.
+*Internal*
++ Test suite explicitly tests with both HTTP/1.1 and HTTP/2.
 
 ** 0.3
 
diff --git a/plz.info b/plz.info
index 2069d516b0..cd1d405cbe 100644
--- a/plz.info
+++ b/plz.info
@@ -281,7 +281,8 @@ File: README.info,  Node: 04-pre,  Next: 03,  Up: Changelog
 3.1 0.4-pre
 ===========
 
-Nothing new yet.
+*Internal*
+   • Test suite explicitly tests with both HTTP/1.1 and HTTP/2.
 
 
 File: README.info,  Node: 03,  Next: 021,  Prev: 04-pre,  Up: Changelog
@@ -390,14 +391,14 @@ Node: Queueing6562
 Node: Tips7820
 Node: Changelog8121
 Node: 04-pre8306
-Node: 038412
-Node: 0218864
-Node: 029013
-Node: 019142
-Node: Credits9236
-Node: Development9602
-Node: Copyright assignment10116
-Node: License10704
+Node: 038472
+Node: 0218924
+Node: 029073
+Node: 019202
+Node: Credits9296
+Node: Development9662
+Node: Copyright assignment10176
+Node: License10764
 
 End Tag Table
 
diff --git a/tests/test-plz.el b/tests/test-plz.el
index 9b4140efaf..23e0613e36 100644
--- a/tests/test-plz.el
+++ b/tests/test-plz.el
@@ -120,6 +120,21 @@
              while (equal 'run (process-status process))
              do (sleep-for seconds))))
 
+(cl-defmacro plz-deftest (name () &body docstring-keys-and-body)
+  "Like `ert-deftest', but defines tests for both HTTP/1.1 and HTTP/2."
+  (declare (debug (&define [&name "test@" symbolp]
+                          sexp [&optional stringp]
+                          [&rest keywordp sexp] def-body))
+           (doc-string 3)
+           (indent 2))
+  `(progn
+     ,@(cl-loop for http-version in '("1.1" "2")
+                collect (let ((name (intern (format "%s-http%s" name 
http-version))))
+                          `(ert-deftest ,name ()
+                             (let ((plz-curl-default-args
+                                    ',(append plz-curl-default-args (list 
(format "--http%s" http-version)))))
+                               ,@docstring-keys-and-body))))))
+
 ;;;; Functions
 
 (defmacro plz-test-get-response (response)
@@ -137,7 +152,7 @@
 
 ;;;;; Async
 
-(ert-deftest plz-get-string nil
+(plz-deftest plz-get-string nil
   (let* ((test-string)
          (process (plz 'get "https://httpbin.org/get";
                     :as 'string
@@ -146,7 +161,7 @@
     (plz-test-wait process)
     (should (string-match "curl" test-string))))
 
-(ert-deftest plz-get-buffer nil
+(plz-deftest plz-get-buffer nil
   ;; The sentinel kills the buffer, so we get the buffer as a string.
   (let* ((test-buffer-string)
          (process (plz 'get "https://httpbin.org/get";
@@ -157,7 +172,7 @@
     (plz-test-wait process)
     (should (string-match "curl" test-buffer-string))))
 
-(ert-deftest plz-get-response nil
+(plz-deftest plz-get-response nil
   (let* ((test-response)
          (process (plz 'get "https://httpbin.org/get";
                     :as 'response
@@ -166,7 +181,7 @@
     (plz-test-wait process)
     (plz-test-get-response test-response)))
 
-(ert-deftest plz-get-json nil
+(plz-deftest plz-get-json nil
   (let* ((test-json)
          (process (plz 'get "https://httpbin.org/get";
                     :as #'json-read
@@ -176,7 +191,7 @@
     (let-alist test-json
       (should (string-match "curl" .headers.User-Agent)))))
 
-(ert-deftest plz-post-json-string nil
+(plz-deftest plz-post-json-string nil
   (let* ((json-string (json-encode (list (cons "key" "value"))))
          (response-json)
          (process (plz 'post "https://httpbin.org/post";
@@ -190,7 +205,7 @@
       (should (string-match "curl" .headers.User-Agent))
       (should (string= "value" (alist-get 'key (json-read-from-string 
.data)))))))
 
-(ert-deftest plz-post-jpeg-string nil
+(plz-deftest plz-post-jpeg-string nil
   (let* ((jpeg-to-upload (plz 'get "https://httpbin.org/image/jpeg";
                            :as 'binary :then 'sync))
          (_ (unless jpeg-to-upload
@@ -216,7 +231,7 @@
 
 ;; TODO: POST JSON buffer.
 
-(ert-deftest plz-put-json-string nil
+(plz-deftest plz-put-json-string nil
   (let* ((json-string (json-encode (list (cons "key" "value"))))
          (response-json)
          (process (plz 'put "https://httpbin.org/put";
@@ -234,21 +249,21 @@
 
 ;;;;; Sync
 
-(ert-deftest plz-get-string-sync nil
+(plz-deftest plz-get-string-sync nil
   (let-alist (json-read-from-string (plz 'get "https://httpbin.org/get";
                                       :as 'string :then 'sync))
     (should (equal "https://httpbin.org/get"; .url))))
 
-(ert-deftest plz-get-response-sync nil
+(plz-deftest plz-get-response-sync nil
   (plz-test-get-response (plz 'get "https://httpbin.org/get";
                            :as 'response :then 'sync)))
 
-(ert-deftest plz-get-json-sync nil
+(plz-deftest plz-get-json-sync nil
   (let-alist (plz 'get "https://httpbin.org/get";
                :as #'json-read :then 'sync)
     (should (string-match "curl" .headers.User-Agent))))
 
-(ert-deftest plz-get-buffer-sync nil
+(plz-deftest plz-get-buffer-sync nil
   (let ((buffer (plz 'get "https://httpbin.org/get";
                   :as 'buffer :then 'sync)))
     (unwind-protect
@@ -260,7 +275,7 @@
 ;; These tests were added when plz--curl was changed to send headers
 ;; with "--config" rather than on the command line.
 
-(ert-deftest plz-get-with-headers ()
+(plz-deftest plz-get-with-headers ()
   (let* ((response-json)
          (process (plz 'get "https://httpbin.org/get";
                     :headers '(("X-Plz-Test-Header" . "plz-test-header-value"))
@@ -271,7 +286,7 @@
     (let-alist response-json
       (should (equal "plz-test-header-value" .headers.X-Plz-Test-Header)))))
 
-(ert-deftest plz-post-with-headers ()
+(plz-deftest plz-post-with-headers ()
   (let* ((alist (list (cons "key" "value")))
          (response-json)
          (process (plz 'post "https://httpbin.org/post";
@@ -286,7 +301,7 @@
       (should (equal "plz-test-header-value" .headers.X-Plz-Test-Header))
       (should (equal "value" (alist-get 'key (json-read-from-string 
.data)))))))
 
-(ert-deftest plz-get-json-with-headers-sync ()
+(plz-deftest plz-get-json-with-headers-sync ()
   (let-alist (plz 'get "https://httpbin.org/get";
                :headers '(("X-Plz-Test-Header" . "plz-test-header-value"))
                :as #'json-read :then 'sync)
@@ -295,7 +310,7 @@
 
 ;;;;; Errors
 
-(ert-deftest plz-get-curl-error nil
+(plz-deftest plz-get-curl-error nil
   ;; Async.
   (let* ((err)
          (process (plz 'get "https://httpbinnnnnn.org/get/status/404";
@@ -311,7 +326,7 @@
 ;; stalls the Emacs process indefinitely, using either sleep-for or
 ;; sit-for.
 
-;; (ert-deftest plz-get-killed-error nil
+;; (plz-deftest plz-get-killed-error nil
 ;;   ;; Async.
 ;;   (let* ((err)
 ;;          (process (plz 'get "https://httpbinnnnnn.org/get/status/404";
@@ -325,7 +340,7 @@
 ;;     (should (equal "curl process killed"
 ;;                    (plz-error-message err)))))
 
-(ert-deftest plz-get-curl-error-sync nil
+(plz-deftest plz-get-curl-error-sync nil
   ;; Sync.
   (let ((err (should-error (plz 'get "https://httpbinnnnnn.org/get/status/404";
                              :as 'string :then 'sync)
@@ -335,7 +350,7 @@
     (should (equal '(6 . "Couldn't resolve host. The given remote host was not 
resolved.")
                    (plz-error-curl-error (cdr err))))))
 
-(ert-deftest plz-get-404-error nil
+(plz-deftest plz-get-404-error nil
   ;; FIXME: Wrap each test expression in `should' rather than using 
`should-and'.
 
   ;; Async.
@@ -358,7 +373,7 @@
                  (plz-response-p (plz-error-response (cdr err)))
                  (eq 404 (plz-response-status (plz-error-response (cdr 
err))))))))
 
-(ert-deftest plz-get-timeout-error nil
+(plz-deftest plz-get-timeout-error nil
   ;; Async.
   (let* ((start-time (current-time))
          (end-time)
@@ -386,7 +401,7 @@
 
 ;;;;; Finally
 
-(ert-deftest plz-get-finally nil
+(plz-deftest plz-get-finally nil
   (let* ((finally-null t)
          (process (plz 'get "https://httpbin.org/get";
                     :as 'string
@@ -398,7 +413,7 @@
 
 ;;;;; Binary
 
-(ert-deftest plz-get-jpeg ()
+(plz-deftest plz-get-jpeg ()
   (let* ((test-jpeg)
          (process (plz 'get "https://httpbin.org/image/jpeg";
                     :as 'binary
@@ -407,14 +422,14 @@
     (plz-test-wait process)
     (should (equal 'jpeg (image-type-from-data test-jpeg)))))
 
-(ert-deftest plz-get-jpeg-sync ()
+(plz-deftest plz-get-jpeg-sync ()
   (let ((jpeg (plz 'get "https://httpbin.org/image/jpeg";
                 :as 'binary :then 'sync)))
     (should (equal 'jpeg (image-type-from-data jpeg)))))
 
 ;;;;; Downloading to files
 
-(ert-deftest plz-get-temp-file ()
+(plz-deftest plz-get-temp-file ()
   (let ((filename (plz 'get "https://httpbin.org/image/jpeg";
                     :as 'file :then 'sync)))
     (unwind-protect
@@ -425,7 +440,7 @@
       ;; It's a temp file, so it should always be deleted.
       (delete-file filename))))
 
-(ert-deftest plz-get-named-file ()
+(plz-deftest plz-get-named-file ()
   (let ((filename (make-temp-file "plz-")))
     ;; HACK: Delete the temp file and reuse its name, because
     ;; `make-temp-name' is less convenient to use.
@@ -446,7 +461,7 @@
 
 ;; TODO: Test that limit is enforced (though it seems to work fine).
 
-(ert-deftest plz-queue ()
+(plz-deftest plz-queue ()
   (let ((queue (make-plz-queue :limit 2))
         (urls '("https://httpbin.org/get?foo=0";
                 "https://httpbin.org/get?foo=1";))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]