-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
108 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
language: erlang | ||
git: | ||
submodules: false | ||
install: true | ||
before_script: | ||
- wget https://s3.amazonaws.com/rebar3/rebar3 | ||
- chmod +x rebar3 | ||
env: PATH=$PATH:. | ||
script: rebar3 eunit | ||
notifications: | ||
email: [email protected] | ||
otp_release: | ||
- 18.2 | ||
- 17.5 | ||
- R16B03-1 | ||
- R15B03 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule doc
updated
from a613c0 to 00ff1d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
(defmodule elli_xpblfe_tests | ||
(behaviour ltest-unit) | ||
(export (elli_xpblfe_test_ 0))) | ||
|
||
(include-lib "ltest/include/ltest-macros.lfe") | ||
|
||
(deftestgen elli_xpblfe | ||
"Tests based on [`elli_middleware_tests`][1]. | ||
[1]: https://github.com/knutin/elli/blob/master/test/elli_middleware_tests.erl" | ||
`#(setup ,(defsetup setup) ,(defteardown teardown) | ||
[,(_test (hello_world)) ,(_test (short_circuit))])) | ||
|
||
|
||
;;;=================================================================== | ||
;;; Tests | ||
;;;=================================================================== | ||
|
||
(defun short_circuit () | ||
(let* ((url "http://localhost:3002/middleware/short-circuit") | ||
(`#(ok ,response) (httpc:request url))) | ||
(is-equal 200 (status response)) | ||
(is-equal "LFE" (x_powered_by response)) | ||
(is-equal "short circuit!" (body response)))) | ||
|
||
(defun hello_world () | ||
(let* ((url "http://localhost:3002/hello/world") | ||
(`#(ok ,response) (httpc:request url))) | ||
(is-equal 200 (status response)) | ||
(is-equal "LFE" (x_powered_by response)) | ||
(is-equal "Hello World!" (body response)))) | ||
|
||
|
||
;;;=================================================================== | ||
;;; Helper functions | ||
;;;=================================================================== | ||
|
||
(defun status ([`#(#(,_ ,status ,_) ,_ ,_)] status)) | ||
|
||
(defun headers ([`#(,_ ,headers ,_)] (lists:sort headers))) | ||
|
||
(defun body ([`#(,_ ,_ ,body)] body)) | ||
|
||
(defun x_powered_by (response) | ||
(proplists:get_value "x-powered-by" (headers response))) | ||
|
||
(defun setup () | ||
(application:ensure_all_started 'inets) | ||
(let* ((config `[#(mods [#(elli_example_middleware []) | ||
#(elli_middlware_compress []) | ||
#(elli_example_callback []) | ||
#(elli_xpblfe [])])]) | ||
(`#(ok ,p) (elli:start_link `[#(callback elli_middleware) | ||
#(callback_args ,config) | ||
#(port 3002)]))) | ||
(unlink p) | ||
`[,p])) | ||
|
||
(defun teardown (pids) (lists:map #'elli:stop/1 pids)) |