branch: elpa/mastodon
commit 5308821c78d4e7b7fd26bd47a1a271700f0a853f
Author: marty hiatt <martianhia...@disroot.org>
Commit: marty hiatt <martianhia...@disroot.org>

    tests: fix three tests, mock for (url-http-parse-response)
---
 test/mastodon-http-tests.el | 36 ++++++++++++++++++++----------------
 test/mastodon-toot-tests.el |  1 +
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/test/mastodon-http-tests.el b/test/mastodon-http-tests.el
index 9e0b413909..4bef0eefe7 100644
--- a/test/mastodon-http-tests.el
+++ b/test/mastodon-http-tests.el
@@ -61,28 +61,32 @@ Strict-Transport-Security: max-age=31536000
   "Should run success function for 200 HTML response."
   (let ((response-buffer
          (get-buffer-create "mastodon-http--triage-buffer")))
-    (with-current-buffer response-buffer
-      (erase-buffer)
-      (insert mastodon-http--example-200))
-    (should (equal (mastodon-http--triage
-                    response-buffer
-                    (lambda (_)
-                      (message "success call")))
-                   "success call"))))
+    (with-mock
+      (mock (url-http-parse-response) => 200)
+      (with-current-buffer response-buffer
+        (erase-buffer)
+        (insert mastodon-http--example-200))
+      (should (equal (mastodon-http--triage
+                      response-buffer
+                      (lambda (_)
+                        (message "success call")))
+                     "success call")))))
 
 (ert-deftest mastodon-http--triage-failure ()
   "Should return formatted JSON error from bad HTML response buffer.
   Should not run success function."
   (let ((response-buffer
          (get-buffer-create "mastodon-http--triage-buffer")))
-    (with-current-buffer response-buffer
-      (erase-buffer)
-      (insert mastodon-http--example-400))
-    (should (equal (mastodon-http--triage
-                    response-buffer
-                    (lambda (_)
-                      (message "success call")))
-                   "Error 444: some unhappy complaint"))))
+    (with-mock
+      (mock (url-http-parse-response) => 444)
+      (with-current-buffer response-buffer
+        (erase-buffer)
+        (insert mastodon-http--example-400))
+      (should (equal (mastodon-http--triage
+                      response-buffer
+                      (lambda (_)
+                        (message "success call")))
+                     "Error 444: some unhappy complaint")))))
 
 (ert-deftest mastodon-http-params-build ()
   "Should correctly format parameters from an alist."
diff --git a/test/mastodon-toot-tests.el b/test/mastodon-toot-tests.el
index b01c36fca5..7d5da284e6 100644
--- a/test/mastodon-toot-tests.el
+++ b/test/mastodon-toot-tests.el
@@ -209,6 +209,7 @@ mention string."
           (toot mastodon-toot-test-base-toot)
           (id 61208))
       (with-mock
+        (mock (url-http-parse-response) => 200)
         (mock (mastodon-tl--property 'base-item-id) => id)
         (mock (mastodon-http--api "statuses/61208/pin")
               => "https://example.space/statuses/61208/pin";)

Reply via email to