diff options
author | Johnson Denen <johnson.denen@gmail.com> | 2017-04-12 18:01:13 -0400 |
---|---|---|
committer | Johnson Denen <johnson.denen@gmail.com> | 2017-04-12 18:11:48 -0400 |
commit | 0c80780a32b6a70c4da30c53fb2f646d6ac79b7a (patch) | |
tree | 4bb8514d91dc0690eb6105f4e4ddea79055ad345 | |
parent | 993dfce9bda9a8562b37dee08a7918e0acfaef78 (diff) |
Add `mastodon-auth--client' function
Replace direct references to `mastodon--client-app-plist'
-rw-r--r-- | lisp/mastodon-auth.el | 6 | ||||
-rw-r--r-- | test/mastodon-auth-tests.el | 11 |
2 files changed, 12 insertions, 5 deletions
diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index 260f838..ef16ab9 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -71,10 +71,14 @@ STATUS is passed by `url-retrieve'." "Return t if `mastodon--client-app-plist' has a :client_secret value." (when (plist-get mastodon--client-app-plist :client_secret) t)) +(defun mastodon-auth--client () + "Return `mastodon--client-app-plist' value." + mastodon--client-app-plist) + (defun mastodon--register-and-return-client-app () "Register `mastodon' with an instance. Return `mastodon--client-app-plist'." (if (mastodon-auth--client-app-secret-p) - mastodon--client-app-plist + (mastodon-auth--client) (progn (mastodon--register-client-app) (sleep-for 2) diff --git a/test/mastodon-auth-tests.el b/test/mastodon-auth-tests.el index 7c2bb0c..1bbc46b 100644 --- a/test/mastodon-auth-tests.el +++ b/test/mastodon-auth-tests.el @@ -43,11 +43,14 @@ => (funcall 'mastodon-auth--registration-success)) (should (eq app-plist (mastodon--register-client-app-triage "status")))))) -(ert-deftest mastodon-auth:register-and-return-client-app () - "Should return a plist of client_id and client_secret after registration." - (let ((app-plist '("id" "id-val" "secret" "secret-val"))) +(ert-deftest mastodon-auth:register-and-return-client-app:with-p () + "Should return a plist of client_id and client_secret without registration." + (let ((app-plist '(:client_id "id-val" :client_secret "secret-val"))) (with-mock - (mock (mastodon--register-client-app) => app-plist) + (mock (mastodon-auth--client-app-secret-p) => t) + (mock (mastodon-auth--client) => app-plist) + (stub mastodon-auth--registration-success => mastodon--client-app-plist) + (not-called sleep-for) (should (equal app-plist (mastodon--register-and-return-client-app)))))) (defun helper:read-plstore (file key) |