aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml9
-rw-r--r--lisp/mastodon-auth--test.el47
-rw-r--r--lisp/mastodon-auth.el1
3 files changed, 49 insertions, 8 deletions
diff --git a/.travis.yml b/.travis.yml
index 6311b0a..5f5796c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,12 +1,7 @@
language: emacs-lisp
sudo: false
before_install:
- - git clone https://github.com/cask/cask ~/.cask
- - PATH=$HOME/.cask/bin:$PATH
- - export PATH="/home/travis/.evm/bin:$PATH"
- # - curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh
- - git clone https://github.com/rejeep/evm.git /home/travis/.evm
- - evm config path /tmp
+ - curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh
- evm install $EVM_EMACS --use --skip
- cask install
env:
@@ -16,7 +11,7 @@ script:
- emacs --version
- cask build
- cask clean-elc
- # - cask exec ert-runner -l test/ert-helper.el test/*-tests.el
+ - cask exec ert-runner -l test/ert-helper.el test/*-tests.el
- cask emacs --batch -Q -l package-lint.el -f package-lint-batch-and-exit lisp/*.el
notifications:
webhooks:
diff --git a/lisp/mastodon-auth--test.el b/lisp/mastodon-auth--test.el
new file mode 100644
index 0000000..8082536
--- /dev/null
+++ b/lisp/mastodon-auth--test.el
@@ -0,0 +1,47 @@
+;;; mastodon-auth--test.el --- Tests for mastodon-auth -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2020 Ian Eure
+
+;; Author: Ian Eure <ian@retrospec.tv>
+;; Version: 0.9.0
+;; Homepage: https://github.com/jdenen/mastodon.el
+;; Package-Requires: ((emacs "24.4"))
+
+;; This file is not part of GNU Emacs.
+
+;; This file is part of mastodon.el.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; mastodon-auth--test.el provides ERT tests for mastodon-auth.el
+
+;;; Code:
+
+(require 'ert)
+
+(ert-deftest mastodon-auth--handle-token-response--good ()
+ (should (string= "foo" (mastodon-auth--handle-token-response '(:access_token "foo" :token_type "Bearer" :scope "read write follow" :created_at 0)))))
+
+(ert-deftest mastodon-auth--handle-token-response--unknown ()
+ :expected-result :failed
+ (mastodon-auth--handle-token-response '(:herp "derp")))
+
+(ert-deftest mastodon-auth--handle-token-response--failure ()
+ :expected-result :failed
+ (mastodon-auth--handle-token-response '(:error "invalid_grant" :error_description "The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.")))
+
+(provide 'mastodon-auth--test)
+;;; mastodon-auth--test.el ends here
diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el
index 74d4404..a3d51fa 100644
--- a/lisp/mastodon-auth.el
+++ b/lisp/mastodon-auth.el
@@ -153,7 +153,6 @@ Handle any errors from the server."
(`(:error ,class :error_description ,error)
(error "Mastodon-auth--access-token: %s: %s" class error))
-
(_ (error "Unknown response from mastodon-auth--get-token!"))))
(defun mastodon-auth--get-account-name ()