diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-09-19 21:02:37 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-09-19 21:02:37 +0100 |
commit | f614c8ed0c4ecc4f1811ad1862af33ba16a2afbd (patch) | |
tree | 56d5a6ee94a978d9dedbaec6d4c964b55ccea80b | |
parent | File event functions can be pure (diff) | |
download | gentoobrowse-api-f614c8ed0c4ecc4f1811ad1862af33ba16a2afbd.tar.bz2 gentoobrowse-api-f614c8ed0c4ecc4f1811ad1862af33ba16a2afbd.tar.xz gentoobrowse-api-f614c8ed0c4ecc4f1811ad1862af33ba16a2afbd.zip |
Tidy overview categories and add test for unhyphenated category name
-rw-r--r-- | gentoobrowse-api/service/portageimpl.cpp | 7 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/fixtures/categories.dat | 1 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/testPortage.cpp | 12 |
3 files changed, 9 insertions, 11 deletions
diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp index 7653976..cf03f23 100644 --- a/gentoobrowse-api/service/portageimpl.cpp +++ b/gentoobrowse-api/service/portageimpl.cpp @@ -62,12 +62,7 @@ Portage::getAllOverviewCategories(const Ice::Current &) auto cats = fetchCache<Gentoo::OverviewCategories>(sql::portage::getAllOverviewCategories, 30); for (const auto & c : cats) { auto hyphen = c->name.find('-'); - if (hyphen == (std::string::npos)-1) { - rtn[c->name].push_back(c); - } - else { - rtn[c->name.substr(0, hyphen)].push_back(c); - } + rtn[c->name.substr(0, hyphen)].push_back(c); } return rtn; } diff --git a/gentoobrowse-api/unittests/fixtures/categories.dat b/gentoobrowse-api/unittests/fixtures/categories.dat index 698aeba..dfe9df9 100644 --- a/gentoobrowse-api/unittests/fixtures/categories.dat +++ b/gentoobrowse-api/unittests/fixtures/categories.dat @@ -3,3 +3,4 @@ 316 app-backup The app-backup category contains tools for performing backups of data, including both full and incremental backups, as well as backups to other media (CD-R, Tape, etc.). 311 dev-vcs The dev-vcs category contains utilities focused on version control. 313 net-proxy The net-proxy category contains network proxy software. +315 virtual The virtual category contains packages which satisfy virtual dependencies. diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp index 2a8dd77..14fe16b 100644 --- a/gentoobrowse-api/unittests/testPortage.cpp +++ b/gentoobrowse-api/unittests/testPortage.cpp @@ -35,11 +35,11 @@ BOOST_AUTO_TEST_CASE( findCategory ) BOOST_AUTO_TEST_CASE( getAllCategories ) { auto cats = p->getAllCategories(); - BOOST_REQUIRE_EQUAL(5, cats.size()); + BOOST_REQUIRE_EQUAL(6, cats.size()); BOOST_REQUIRE_EQUAL(316, cats.front()->categoryid); - BOOST_REQUIRE_EQUAL(313, cats.back()->categoryid); + BOOST_REQUIRE_EQUAL(315, cats.back()->categoryid); BOOST_REQUIRE_EQUAL("app-backup", cats.front()->name); - BOOST_REQUIRE_EQUAL("net-proxy", cats.back()->name); + BOOST_REQUIRE_EQUAL("virtual", cats.back()->name); } BOOST_AUTO_TEST_CASE( getCategoriesInSuper ) @@ -75,13 +75,15 @@ BOOST_AUTO_TEST_CASE( getCategoriesWithRecentAdditions ) BOOST_AUTO_TEST_CASE( getAllOverviewCategories ) { auto cats = p->getAllOverviewCategories(); - BOOST_REQUIRE_EQUAL(3, cats.size()); + BOOST_REQUIRE_EQUAL(4, cats.size()); BOOST_REQUIRE_EQUAL("app", cats.begin()->first); BOOST_REQUIRE_EQUAL(2, cats["app"].size()); BOOST_REQUIRE_EQUAL("app-backup", cats["app"].front()->name); BOOST_REQUIRE_EQUAL("app-crypt", cats["app"].back()->name); BOOST_REQUIRE_EQUAL("2015-12-02T19:12:59.916989", cats["app"].back()->lastaddition); - BOOST_REQUIRE_EQUAL("net", cats.rbegin()->first); + BOOST_REQUIRE_EQUAL("virtual", cats.rbegin()->first); + BOOST_REQUIRE_EQUAL(1, cats.rbegin()->second.size()); + BOOST_REQUIRE_EQUAL("virtual", cats["virtual"].front()->name); } BOOST_AUTO_TEST_CASE( getOverviewCategoriesInSuper ) |