Skip to content

Commit

Permalink
[#4] Add trails basic tests to Common Test Suite
Browse files Browse the repository at this point in the history
  • Loading branch information
davecaos committed Jun 25, 2015
1 parent 2ab1c45 commit b3dab95
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions test/trails_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
-export([all/0]).
-export([init_per_suite/1]).
-export([end_per_suite/1]).
-export([basic_compile_test/1]).
-export([minimal_compile_test/1]).
-export([static_compile_test/1]).

-type config() :: [{atom(), term()}].

Expand All @@ -27,3 +30,53 @@ end_per_suite(Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Test Cases
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-spec minimal_compile_test(config()) -> config().
minimal_compile_test(Config) ->
MininalRoute = [{'_',[]}],
ExpectedResponse = [{'_',[],[]}],
ExpectedResponse = trails:compile(MininalRoute),
Config.

-spec basic_compile_test(config()) -> config().
basic_compile_test(Config) ->
BasicRoute =
[
{"localhost",
[
{"/such/path", http_such_path_handler, []},
{"/very", http_very, []},
{"/", http_handler, []}
]}
],
ExpectedResponse =
[{
[<<"localhost">>], [],
[
{[<<"such">>,<<"path">>], [], http_such_path_handler,[]},
{[<<"very">>], [], http_very, []},
{[], [], http_handler, []}
]}
],
ExpectedResponse = trails:compile(BasicRoute),
Config.

-spec static_compile_test(config()) -> config().
static_compile_test(Config) ->
StaticRoute =
[
{'_',
[
{"/", cowboy_static, {private_file, something, "index.html"}}
]}
],
ExpectedResponse =
[
{'_', [],
[
{[], [],cowboy_static, {private_file, something, "index.html"}}
]}
],
ExpectedResponse = trails:compile(StaticRoute),
Config.

0 comments on commit b3dab95

Please sign in to comment.