Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Commit

Permalink
Add a test framework and the first test for parsing the request error
Browse files Browse the repository at this point in the history
  • Loading branch information
dakrone committed Jul 19, 2016
1 parent 7ffd133 commit dd92922
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.elc
.ert-runner
.cask
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: generic
sudo: false
before_install:
- curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh
- evm install $EVM_EMACS --use --skip
- cask
env:
- EVM_EMACS=emacs-24.1-travis
- EVM_EMACS=emacs-24.2-travis
- EVM_EMACS=emacs-24.3-travis
- EVM_EMACS=emacs-24.4-travis
- EVM_EMACS=emacs-24.5-travis
script:
- emacs --version
- make test

notifications:
email: false
12 changes: 12 additions & 0 deletions Cask
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(source gnu)
(source melpa)

(files "*.el")

(development
(depends-on "f")
(depends-on "ecukes")
(depends-on "ert-runner")
(depends-on "el-mock")
(depends-on "request")
(depends-on "cask-package-toolset"))
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CASK ?= cask
EMACS ?= emacs

all: test

test: unit #ecukes

unit:
${CASK} exec ert-runner

ecukes:
${CASK} exec ecukes

install:
${CASK} install
19 changes: 19 additions & 0 deletions test/matrix-client-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
;;; Test for `matrix-client'

;;; Commentary:
;; These are the tests for `matrix-client'

;;; Code:

(require 'matrix-helpers)

(ert-deftest matrix-parse-curl ()
(should
(eq 51
(matrix-parse-curl-exit-code "exited abnormally with code 51")))
(should
(eq 60
(matrix-parse-curl-exit-code "exited abnormally with code 60")))
(should
(eq nil
(matrix-parse-curl-exit-code "bagels and beans"))))
41 changes: 41 additions & 0 deletions test/test-helper.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
;;; test-helper --- Test helper for matrix-client

;;; Commentary:
;; test helper inspired from https://github.com/tonini/overseer.el/blob/master/test/test-helper.el

;;; Code:

(require 'f)

(defvar cpt-path
(f-parent (f-this-file)))

(defvar matrix-client-test-path
(f-dirname (f-this-file)))

(defvar matrix-client-root-path
(f-parent matrix-client-test-path))

(defvar matrix-client-sandbox-path
(f-expand "sandbox" matrix-client-test-path))

(when (f-exists? matrix-client-sandbox-path)
(error "Something is already in %s. Check and destroy it yourself" matrix-client-sandbox-path))

(defmacro within-sandbox (&rest body)
"Evaluate BODY in an empty sandbox directory."
`(let ((default-directory matrix-client-sandbox-path))
(when (f-exists? matrix-client-sandbox-path)
(f-delete default-directory :force))
(f-mkdir matrix-client-sandbox-path)
,@body
(f-delete default-directory :force)))

(require 'ert)
(require 'el-mock)
(eval-when-compile
(require 'cl))
(require 'matrix-client)

(provide 'test-helper)
;;; test-helper.el ends here

0 comments on commit dd92922

Please sign in to comment.