aboutsummaryrefslogtreecommitdiff
path: root/test/mastodon-client-tests.el
diff options
context:
space:
mode:
authorHolger Dürer <me@hdurer.net>2021-11-02 20:30:27 +0100
committerHolger Dürer <me@hdurer.net>2021-11-06 16:09:19 +0100
commit93950dbee4165c733fd8e0a4938fd7d0f462d908 (patch)
tree8a25fb5555800fc6c60159e8bbce2059b87f6ac8 /test/mastodon-client-tests.el
parentb9d5d2ee57855653c32fe2fe2a495e5a3a038acf (diff)
Reformat all code.
Basically, in Emacs for each file: select all text and `indent-region`. - This also removes one redundant comment, and - fixes an error with json decoding where the `json-read-from-string` was actually not within the intended `unless` clause (which explains the warning about "result of (string-equal "" json-string) will be ignored" which I never understood.
Diffstat (limited to 'test/mastodon-client-tests.el')
-rw-r--r--test/mastodon-client-tests.el64
1 files changed, 32 insertions, 32 deletions
diff --git a/test/mastodon-client-tests.el b/test/mastodon-client-tests.el
index dfe175b..d7f750d 100644
--- a/test/mastodon-client-tests.el
+++ b/test/mastodon-client-tests.el
@@ -17,30 +17,30 @@
"Should return client registration JSON."
(with-temp-buffer
(with-mock
- (mock (mastodon-client--register) => (progn
- (insert "\n\n{\"foo\":\"bar\"}")
- (current-buffer)))
- (should (equal (mastodon-client--fetch) '(:foo "bar"))))))
+ (mock (mastodon-client--register) => (progn
+ (insert "\n\n{\"foo\":\"bar\"}")
+ (current-buffer)))
+ (should (equal (mastodon-client--fetch) '(:foo "bar"))))))
(ert-deftest store-1 ()
"Should return the client plist."
(let ((mastodon-instance-url "http://mastodon.example")
(plist '(:client_id "id" :client_secret "secret")))
(with-mock
- (mock (mastodon-client--token-file) => "stubfile.plstore")
- (mock (mastodon-client--fetch) => '(:client_id "id" :client_secret "secret"))
- (let* ((plstore (plstore-open "stubfile.plstore"))
- (client (cdr (plstore-get plstore "mastodon-http://mastodon.example"))))
- (should (equal (mastodon-client--store) plist))))))
+ (mock (mastodon-client--token-file) => "stubfile.plstore")
+ (mock (mastodon-client--fetch) => '(:client_id "id" :client_secret "secret"))
+ (let* ((plstore (plstore-open "stubfile.plstore"))
+ (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'."
- (let* ((mastodon-instance-url "http://mastodon.example")
- (plstore (plstore-open "stubfile.plstore"))
- (client (cdr (plstore-get plstore "mastodon-http://mastodon.example"))))
- (plstore-close plstore)
- (should (string= (plist-get client :client_id) "id"))
- (should (string= (plist-get client :client_secret) "secret"))))
+ "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"))))
+ (plstore-close plstore)
+ (should (string= (plist-get client :client_id) "id"))
+ (should (string= (plist-get client :client_secret) "secret"))))
(ert-deftest read-finds-match ()
"Should return mastodon client from `mastodon-token-file' if it exists."
@@ -60,8 +60,8 @@
(ert-deftest 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))))
+ (mock (mastodon-client--token-file) => "fixture/empty.plstore")
+ (should (equal (mastodon-client--read) nil))))
(ert-deftest client-set-and-matching ()
"Should return `mastondon-client' if `mastodon-client--client-details-alist' is non-nil and instance url is included."
@@ -75,29 +75,29 @@
(let ((mastodon-instance-url "http://mastodon.example")
(mastodon-client--client-details-alist '(("http://other.example" :wrong))))
(with-mock
- (mock (mastodon-client--read) => '(:client_id "foo" :client_secret "bar"))
- (should (equal (mastodon-client) '(:client_id "foo" :client_secret "bar")))
- (should (equal mastodon-client--client-details-alist
- '(("http://mastodon.example" :client_id "foo" :client_secret "bar")
- ("http://other.example" :wrong)))))))
+ (mock (mastodon-client--read) => '(:client_id "foo" :client_secret "bar"))
+ (should (equal (mastodon-client) '(:client_id "foo" :client_secret "bar")))
+ (should (equal mastodon-client--client-details-alist
+ '(("http://mastodon.example" :client_id "foo" :client_secret "bar")
+ ("http://other.example" :wrong)))))))
(ert-deftest client-unset ()
"Should read from `mastodon-token-file' if available."
(let ((mastodon-instance-url "http://mastodon.example")
(mastodon-client--client-details-alist nil))
(with-mock
- (mock (mastodon-client--read) => '(:client_id "foo" :client_secret "bar"))
- (should (equal (mastodon-client) '(:client_id "foo" :client_secret "bar")))
- (should (equal mastodon-client--client-details-alist
- '(("http://mastodon.example" :client_id "foo" :client_secret "bar")))))))
+ (mock (mastodon-client--read) => '(:client_id "foo" :client_secret "bar"))
+ (should (equal (mastodon-client) '(:client_id "foo" :client_secret "bar")))
+ (should (equal mastodon-client--client-details-alist
+ '(("http://mastodon.example" :client_id "foo" :client_secret "bar")))))))
(ert-deftest 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))
(with-mock
- (mock (mastodon-client--read))
- (mock (mastodon-client--store) => '(:client_id "foo" :client_secret "baz"))
- (should (equal (mastodon-client) '(:client_id "foo" :client_secret "baz")))
- (should (equal mastodon-client--client-details-alist
- '(("http://mastodon.example" :client_id "foo" :client_secret "baz")))))))
+ (mock (mastodon-client--read))
+ (mock (mastodon-client--store) => '(:client_id "foo" :client_secret "baz"))
+ (should (equal (mastodon-client) '(:client_id "foo" :client_secret "baz")))
+ (should (equal mastodon-client--client-details-alist
+ '(("http://mastodon.example" :client_id "foo" :client_secret "baz")))))))