aboutsummaryrefslogtreecommitdiff
path: root/test/mastodon-client-tests.el
diff options
context:
space:
mode:
authorHolger Dürer <me@hdurer.net>2021-11-09 18:24:54 +0100
committerHolger Dürer <me@hdurer.net>2021-11-10 20:12:12 +0100
commit522926bcca0caf45516da3dcd00c944066641965 (patch)
treea53083dd1483f06e7833e0e0dacbf080cff15293 /test/mastodon-client-tests.el
parent5df05d94926ada6843cbc65aea4b64c18429fdf1 (diff)
Hamonize tests.
- Add a header comment explicitly switching off lexical binding - Harmonize naming (always start with module and double hyphen) - Ensure all tests have at least a minimal doc string. - Move tests from `mastodon-auth-test.el` to `mastodon-auth-tests.el`
Diffstat (limited to 'test/mastodon-client-tests.el')
-rw-r--r--test/mastodon-client-tests.el26
1 files changed, 14 insertions, 12 deletions
diff --git a/test/mastodon-client-tests.el b/test/mastodon-client-tests.el
index 12d2350..b112729 100644
--- a/test/mastodon-client-tests.el
+++ b/test/mastodon-client-tests.el
@@ -1,6 +1,8 @@
+;;; mastodon-client-test.el --- Tests for mastodon-client.el -*- lexical-binding: nil -*-
+
(require 'el-mock)
-(ert-deftest register ()
+(ert-deftest mastodon-client--register ()
"Should POST to /apps."
(with-mock
(mock (mastodon-http--api "apps") => "https://instance.url/api/v1/apps")
@@ -13,7 +15,7 @@
:unauthenticated))
(mastodon-client--register)))
-(ert-deftest fetch ()
+(ert-deftest mastodon-client--fetch ()
"Should return client registration JSON."
(with-temp-buffer
(with-mock
@@ -22,7 +24,7 @@
(current-buffer)))
(should (equal (mastodon-client--fetch) '(:foo "bar"))))))
-(ert-deftest store-1 ()
+(ert-deftest mastodon-client--store-1 ()
"Should return the client plist."
(let ((mastodon-instance-url "http://mastodon.example")
(plist '(:client_id "id" :client_secret "secret")))
@@ -33,8 +35,8 @@
(client (cdr (plstore-get plstore "mastodon-http://mastodon.example"))))
(should (equal (mastodon-client--store) plist))))))
-(ert-deftest store-2 ()
- "Should store client in `mastodon-client--token-file'."
+(ert-deftest mastodon-client--store-2 ()
+ "Should store client in `mastodon-client--token-file'."
(let* ((mastodon-instance-url "http://mastodon.example")
(plstore (plstore-open "stubfile.plstore"))
(client (cdr (plstore-get plstore "mastodon-http://mastodon.example"))))
@@ -42,7 +44,7 @@
(should (string= (plist-get client :client_id) "id"))
(should (string= (plist-get client :client_secret) "secret"))))
-(ert-deftest read-finds-match ()
+(ert-deftest mastodon-client--read-finds-match ()
"Should return mastodon client from `mastodon-token-file' if it exists."
(let ((mastodon-instance-url "http://mastodon.example"))
(with-mock
@@ -50,27 +52,27 @@
(should (equal (mastodon-client--read)
'(:client_id "id2" :client_secret "secret2"))))))
-(ert-deftest read-finds-no-match ()
+(ert-deftest mastodon-client--read-finds-no-match ()
"Should return mastodon client from `mastodon-token-file' if it exists."
(let ((mastodon-instance-url "http://mastodon.social"))
(with-mock
(mock (mastodon-client--token-file) => "fixture/client.plstore")
(should (equal (mastodon-client--read) nil)))))
-(ert-deftest read-empty-store ()
+(ert-deftest mastodon-client--read-empty-store ()
"Should return nil if mastodon client is not present in the plstore."
(with-mock
(mock (mastodon-client--token-file) => "fixture/empty.plstore")
(should (equal (mastodon-client--read) nil))))
-(ert-deftest client-set-and-matching ()
+(ert-deftest mastodon-client--client-set-and-matching ()
"Should return `mastondon-client' if `mastodon-client--client-details-alist' is non-nil and instance url is included."
(let ((mastodon-instance-url "http://mastodon.example")
(mastodon-client--client-details-alist '(("https://other.example" . :no-match)
("http://mastodon.example" . :matches))))
(should (eq (mastodon-client) :matches))))
-(ert-deftest client-set-but-not-matching ()
+(ert-deftest mastodon-client--client-set-but-not-matching ()
"Should read from `mastodon-token-file' if wrong data is cached."
(let ((mastodon-instance-url "http://mastodon.example")
(mastodon-client--client-details-alist '(("http://other.example" :wrong))))
@@ -81,7 +83,7 @@
'(("http://mastodon.example" :client_id "foo" :client_secret "bar")
("http://other.example" :wrong)))))))
-(ert-deftest client-unset ()
+(ert-deftest mastodon-client--client-unset ()
"Should read from `mastodon-token-file' if available."
(let ((mastodon-instance-url "http://mastodon.example")
(mastodon-client--client-details-alist nil))
@@ -91,7 +93,7 @@
(should (equal mastodon-client--client-details-alist
'(("http://mastodon.example" :client_id "foo" :client_secret "bar")))))))
-(ert-deftest client-unset-and-not-in-storage ()
+(ert-deftest mastodon-client--client-unset-and-not-in-storage ()
"Should store client data in plstore if it can't be read."
(let ((mastodon-instance-url "http://mastodon.example")
(mastodon-client--client-details-alist nil))