summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-01-21 13:58:59 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2017-01-21 13:58:59 +0000
commit0f4e209094249d39c75c42d45b22d5c9ef556396 (patch)
tree85fea929375c88f650e08fb5375e263049075cc2
parentAdd missing method to get package URLs (diff)
downloadgentoobrowse-api-0.7.3.tar.bz2
gentoobrowse-api-0.7.3.tar.xz
gentoobrowse-api-0.7.3.zip
Fix getUse for cases where a flag is only package localgentoobrowse-api-0.7.3
-rw-r--r--gentoobrowse-api/service/portageimpl.cpp2
-rw-r--r--gentoobrowse-api/service/sql/portage/getUse.sql8
-rw-r--r--gentoobrowse-api/unittests/testPortage.cpp23
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();