/priv/sites/testsandbox/tests/testsandbox_basic_tests.erl

https://code.google.com/p/zotonic/ · Erlang · 26 lines · 18 code · 5 blank · 3 comment · 0 complexity · 220d0c561c5e596ea1dd0051a5a94e03 MD5 · raw file

  1. -module(testsandbox_basic_tests).
  2. -include_lib("eunit/include/eunit.hrl").
  3. %% Test if the site-specific testsandbox module is installed and running.
  4. testsandbox_enabled_test() ->
  5. C = z_context:new(testsandbox),
  6. ?assertEqual(z_module_manager:active(testsandbox, C), true),
  7. ok.
  8. %% Test if some default modules are running.
  9. default_modules_test() ->
  10. C = z_context:new(testsandbox),
  11. ?assertEqual(z_module_manager:active(mod_base, C), true),
  12. ?assertEqual(z_module_manager:active(mod_admin, C), true),
  13. ok.
  14. %% Test if the webserver is running, by looking at the home tpl.
  15. testsandbox_site_up_test() ->
  16. C = z_context:new(testsandbox),
  17. X = http:request(get, {"http://" ++ z_context:hostname_port(C) ++ "/", []}, [], []),
  18. ?assertMatch({ok,{{"HTTP/1.1",200,"OK"}, _, _}}, X),
  19. {ok,{_, _, Body}} = X,
  20. ?assertMatch({match, _}, re:run(Body, "<title>Zotonic test sandbox</title>")),
  21. ok.