From 40a54819cfcba889a812c721d4cc0743ce5ae544 Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Wed, 12 Apr 2017 12:04:03 -0400 Subject: Abstract success lambda to its own function and test Add `mastodon-auth--get-token-success' Add test for `mastodon-auth--get-token-success' Add test for `mastodon--get-access-token-triage' --- lisp/mastodon-auth.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-auth.el') diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index bc09403..9ded694 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -100,16 +100,18 @@ If no data can be found in the token file, registers the app and stores its data (setq mastodon--client-app-plist (mastodon--store-client-id-and-secret)) mastodon--client-app-plist))))) +(defun mastodon-auth--get-token-success () + (let ((token-data (mastodon--json-hash-table))) + (progn + (setq mastodon--api-token-string (gethash "access_token" token-data)) + mastodon--api-token-string))) + (defun mastodon--get-access-token-triage (status) "Callback function to triage `mastodon--get-access-token' response. STATUS is passed by `url-retrieve'." (mastodon--http-response-triage status - (lambda () - (let ((token-data (mastodon--json-hash-table))) - (progn - (setq mastodon--api-token-string (gethash "access_token" token-data)) - mastodon--api-token-string))))) + 'mastodon-auth--get-token-success)) (defun mastodon--get-access-token () "Retrieve access token from instance. -- cgit v1.2.3