diff options
-rw-r--r-- | gentoobrowse-api/service/portageimpl.cpp | 2 | ||||
-rw-r--r-- | gentoobrowse-api/service/sql/portage/getUse.sql | 8 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/testPortage.cpp | 23 |
3 files changed, 30 insertions, 3 deletions
diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp index bb8a215..7677ceb 100644 --- a/gentoobrowse-api/service/portageimpl.cpp +++ b/gentoobrowse-api/service/portageimpl.cpp @@ -220,7 +220,7 @@ Portage::getPackageUses(Ice::Int id, const Ice::Current &) Gentoo::UsePtr Portage::getUse(const std::string & use, const Ice::Current &) { - return fetchCache<Gentoo::UsePtr>(sql::portage::getUse, 30, use); + return fetchCache<Gentoo::UsePtr>(sql::portage::getUse, 30, use, use); } Gentoo::Uses diff --git a/gentoobrowse-api/service/sql/portage/getUse.sql b/gentoobrowse-api/service/sql/portage/getUse.sql index 79e9ba1..2e396a1 100644 --- a/gentoobrowse-api/service/sql/portage/getUse.sql +++ b/gentoobrowse-api/service/sql/portage/getUse.sql @@ -1,4 +1,10 @@ -- libdbpp:no-cursor -SELECT use, description +SELECT use, description, NULL packageid FROM gentoobrowse.use_global WHERE use = ? +UNION +SELECT use, description, packageid +FROM gentoobrowse.use_local +WHERE use = ? +ORDER BY 3 NULLS FIRST +LIMIT 1 diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp index b235c4e..aa10ee9 100644 --- a/gentoobrowse-api/unittests/testPortage.cpp +++ b/gentoobrowse-api/unittests/testPortage.cpp @@ -342,7 +342,7 @@ BOOST_AUTO_TEST_CASE( getPackageUses ) BOOST_REQUIRE(!us[2]->packageid); } -BOOST_AUTO_TEST_CASE( getUse ) +BOOST_AUTO_TEST_CASE( getUseGlobalOnly ) { auto u = p->getUse("X"); BOOST_REQUIRE_EQUAL("X", u->use); @@ -357,6 +357,27 @@ BOOST_AUTO_TEST_CASE( getUseMissing ) BOOST_REQUIRE_THROW(p->getUse("nothing"), Slicer::NoRowsReturned); } +BOOST_AUTO_TEST_CASE( getUseLocalOnly ) +{ + auto u = p->getUse("vistafree"); + BOOST_REQUIRE_EQUAL("vistafree", u->use); + BOOST_REQUIRE_EQUAL("Installs the free Vista ophcrack tables", u->description); + BOOST_REQUIRE(u->packageid); + BOOST_REQUIRE_EQUAL(43076, *u->packageid); + BOOST_REQUIRE(!u->isdefault); + BOOST_REQUIRE(!u->group); +} + +BOOST_AUTO_TEST_CASE( getUseLocalAndGlobal ) +{ + auto u = p->getUse("sasl"); + BOOST_REQUIRE_EQUAL("sasl", u->use); + BOOST_REQUIRE_EQUAL("Add support for the Simple Authentication and Security Layer", u->description); + BOOST_REQUIRE(!u->packageid); + BOOST_REQUIRE(!u->isdefault); + BOOST_REQUIRE(!u->group); +} + BOOST_AUTO_TEST_CASE( getGlobalUses ) { auto us = p->getGlobalUses(); |