diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-23 15:22:30 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-16 21:47:53 +0000 |
commit | d3465d0d00edd302c9d6fc7672a9405921a6a7db (patch) | |
tree | 2bee0f3b25388fefe03029872f5ebed6e05bb970 /gentoobrowse/src | |
parent | Line in the sand, all basic functionality is working (diff) | |
download | gentoobrowse-d3465d0d00edd302c9d6fc7672a9405921a6a7db.tar.bz2 gentoobrowse-d3465d0d00edd302c9d6fc7672a9405921a6a7db.tar.xz gentoobrowse-d3465d0d00edd302c9d6fc7672a9405921a6a7db.zip |
Add basic icespider tests and check core pages with tidy
Diffstat (limited to 'gentoobrowse/src')
-rw-r--r-- | gentoobrowse/src/Jamfile.jam | 40 | ||||
-rw-r--r-- | gentoobrowse/src/test.cpp | 126 |
2 files changed, 158 insertions, 8 deletions
diff --git a/gentoobrowse/src/Jamfile.jam b/gentoobrowse/src/Jamfile.jam index 96b77e5..1e070a1 100644 --- a/gentoobrowse/src/Jamfile.jam +++ b/gentoobrowse/src/Jamfile.jam @@ -1,22 +1,25 @@ import icespider ; +import testing ; +lib icespider-core ; lib icespider-common ; lib icespider-xslt : : : : <library>../..//libxmlpp ; lib icespider-fcgi ; lib icespider-filesessions ; +lib icespider-testing ; lib adhocutil ; lib Ice ; lib IceUtil ; lib pthread ; lib boost_system ; +lib boost_filesystem ; lib slicer ; lib slicer-json ; lib slicer-xml ; lib slicer-db ; +lib boost_unit_test_framework ; lib gentoobrowse-domain ; -lib gentoobrowse : : - <name>gentoobrowse-api - : : +lib gentoobrowse-api : : : : <include>/usr/share/gentoobrowse-api <include>/usr/share/slicer/ice <include>/usr/include/gentoobrowse-api @@ -34,7 +37,6 @@ lib icespider : : <include>/usr/share/icespider/ice <library>icespider-common <library>icespider-xslt - <library>icespider-fcgi <library>icespider-filesessions <library>adhocutil <library>Ice @@ -45,15 +47,37 @@ lib icespider : : <allow-ice>yes ; -exe gentoobrowse-cgi : - [ glob *.cpp *.ice *.json ] +lib gentoobrowse : + [ glob *.cpp *.ice *.json : test.cpp ] : <variant>release:<cxxflags>-flto=3 <variant>release:<linkflags>-flto=3 <slicer>yes <include>. - <library>icespider - <library>gentoobrowse + <library>gentoobrowse-api <library>slicer-json <library>slicer-xml + <library>icespider + : : + <library>icespider ; + +exe gentoobrowse-cgi : + gentoobrowse + : + <library>gentoobrowse + <library>icespider-fcgi + <link>shared + ; + +path-constant me : . ; +run + test.cpp + : : : + <define>BOOST_TEST_DYN_LINK + <define>ROOT=\"$(me)\" + <library>boost_filesystem + <library>gentoobrowse + <library>icespider-testing + <library>boost_unit_test_framework + : gentoobrowse-test ; diff --git a/gentoobrowse/src/test.cpp b/gentoobrowse/src/test.cpp new file mode 100644 index 0000000..994a8df --- /dev/null +++ b/gentoobrowse/src/test.cpp @@ -0,0 +1,126 @@ +#define BOOST_TEST_MODULE TestGentooBrowse +#include <boost/test/unit_test.hpp> + +#include <core.h> +#include <definedDirs.h> +#include <boost/filesystem/operations.hpp> +#include <testRequest.h> + +using namespace IceSpider; + +class ChromiumRequest : public TestRequest { + public: + ChromiumRequest(const Core * c, HttpMethod m, const std::string & p) : + TestRequest(c, m, p) + { + hdr["User-Agent"] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.21 Safari/537.36"; + hdr["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; + hdr["Accept-Encoding"] = "gzip, deflate, sdch"; + hdr["Accept-Language"] = "en-GB,en;q=0.8"; + } + + void standardAssertions(const char * name) + { + auto h = getResponseHeaders(); + BOOST_REQUIRE_EQUAL(h["Status"], "200 OK"); + BOOST_REQUIRE_EQUAL(h["Content-Type"], "text/html"); + validateHtml(name); + } + + void validateHtml(const char * name) + { + char buf[BUFSIZ]; + sprintf(buf, "tidy --indent yes --wrap 0 -quiet -output %s/%s.html", + binDir.c_str(), name); + FILE * tidy = popen(buf, "w"); + while (fwrite(buf, output.readsome(buf, BUFSIZ), 1, tidy) > 0) ; + BOOST_REQUIRE_EQUAL(0, pclose(tidy)); + } +}; + +BOOST_AUTO_TEST_CASE( cd ) +{ + boost::filesystem::current_path(rootDir.parent_path()); +} + +BOOST_FIXTURE_TEST_SUITE(ta, CoreWithDefaultRouter); + +BOOST_AUTO_TEST_CASE( endpointCount ) +{ + BOOST_REQUIRE_EQUAL(22, AdHoc::PluginManager::getDefault()->getAll<IceSpider::RouteHandlerFactory>().size()); + BOOST_REQUIRE_EQUAL(5, routes.size()); +} + +BOOST_AUTO_TEST_CASE( home ) +{ + ChromiumRequest request(this, HttpMethod::GET, "/"); + process(&request); + request.standardAssertions(typeid(this).name()); +} + +BOOST_AUTO_TEST_CASE( news ) +{ + ChromiumRequest request(this, HttpMethod::GET, "/news"); + process(&request); + request.standardAssertions(typeid(this).name()); +} + +BOOST_AUTO_TEST_CASE( news_ruby_20_removal ) +{ + ChromiumRequest request(this, HttpMethod::GET, "/news/2016-12-06-ruby-20-removal"); + process(&request); + request.standardAssertions(typeid(this).name()); +} + +BOOST_AUTO_TEST_CASE( packages ) +{ + ChromiumRequest request(this, HttpMethod::GET, "/packages"); + process(&request); + request.standardAssertions(typeid(this).name()); +} + +BOOST_AUTO_TEST_CASE( packages_popular ) +{ + ChromiumRequest request(this, HttpMethod::GET, "/packages/popular"); + process(&request); + request.standardAssertions(typeid(this).name()); +} + +BOOST_AUTO_TEST_CASE( packages_virtual ) +{ + ChromiumRequest request(this, HttpMethod::GET, "/packages/virtual"); + process(&request); + request.standardAssertions(typeid(this).name()); +} + +BOOST_AUTO_TEST_CASE( packages_virtual_cron ) +{ + ChromiumRequest request(this, HttpMethod::GET, "/packages/virtual/cron"); + process(&request); + request.standardAssertions(typeid(this).name()); +} + +BOOST_AUTO_TEST_CASE( use ) +{ + ChromiumRequest request(this, HttpMethod::GET, "/use"); + process(&request); + request.standardAssertions(typeid(this).name()); +} + +BOOST_AUTO_TEST_CASE( use_gles ) +{ + ChromiumRequest request(this, HttpMethod::GET, "/use/gles"); + process(&request); + request.standardAssertions(typeid(this).name()); +} + +BOOST_AUTO_TEST_CASE( search_default ) +{ + ChromiumRequest request(this, HttpMethod::GET, "/search"); + request.qs["criteria"] = "default"; + process(&request); + request.standardAssertions(typeid(this).name()); +} + +BOOST_AUTO_TEST_SUITE_END(); + |