From 523bf47c32d52d9bc99912d901ec5e6708f21fa5 Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Wed, 12 Apr 2017 22:43:23 -0400 Subject: Add GET function --- lisp/mastodon-http.el | 7 +++++++ test/mastodon-http-tests.el | 10 ++++++++++ 2 files changed, 17 insertions(+) create mode 100644 test/mastodon-http-tests.el diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index aafef8a..91036be 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -109,5 +109,12 @@ If response code is not 2XX, switches to the response buffer created by `url-ret (funcall success) (switch-to-buffer (current-buffer)))) +(defun mastodon-http--get (url callback) + "Make GET request to URL. + +Pass response buffer to CALLBACK function." + (let ((url-request-method "GET")) + (url-retrieve url callback))) + (provide 'mastodon-http) ;;; mastodon-http.el ends here diff --git a/test/mastodon-http-tests.el b/test/mastodon-http-tests.el new file mode 100644 index 0000000..afc8fe3 --- /dev/null +++ b/test/mastodon-http-tests.el @@ -0,0 +1,10 @@ +(require 'el-mock) + +(load-file "../lisp/mastodon-http.el") + +(ert-deftest mastodon-http:get:retrieves-endpoint () + "Should make a `url-retrieve' of the given URL." + (let ((callback-double (lambda () "double"))) + (with-mock + (mock (url-retrieve "https://foo.bar/baz" 'callback-double)) + (mastodon-http--get "https://foo.bar/baz" 'callback-double)))) -- cgit v1.2.3