summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-04-10 15:11:53 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2017-04-10 15:11:53 +0100
commitee0037b33bc63a1b05f22694aabf87df6f0db864 (patch)
treefc114e51fcb0a68379ed8a0ae7f1084d9f95a7f0
parentUpdate service such that recently ebuilds operations work with sync days, not... (diff)
downloadgentoobrowse-api-ee0037b33bc63a1b05f22694aabf87df6f0db864.tar.bz2
gentoobrowse-api-ee0037b33bc63a1b05f22694aabf87df6f0db864.tar.xz
gentoobrowse-api-ee0037b33bc63a1b05f22694aabf87df6f0db864.zip
Fix assertions and validate row count in SQL require equal
-rw-r--r--gentoobrowse-api/unittests/Jamfile.jam1
-rw-r--r--gentoobrowse-api/unittests/mockDefs.h7
-rw-r--r--gentoobrowse-api/unittests/testMaintenance.cpp4
3 files changed, 8 insertions, 4 deletions
diff --git a/gentoobrowse-api/unittests/Jamfile.jam b/gentoobrowse-api/unittests/Jamfile.jam
index 9f60eb4..1876d46 100644
--- a/gentoobrowse-api/unittests/Jamfile.jam
+++ b/gentoobrowse-api/unittests/Jamfile.jam
@@ -30,6 +30,7 @@ lib testCommon :
<library>..//IceBox
<library>dryice
<library>../service//gentoobrowse-service
+ <library>boost_utf
: :
<library>dbpp-postgresql
<library>..//dbppcore
diff --git a/gentoobrowse-api/unittests/mockDefs.h b/gentoobrowse-api/unittests/mockDefs.h
index 586079f..d69d3e1 100644
--- a/gentoobrowse-api/unittests/mockDefs.h
+++ b/gentoobrowse-api/unittests/mockDefs.h
@@ -10,7 +10,7 @@
#include <notifications.h>
#include <mocks.h>
#include <selectcommandUtil.impl.h>
-#include <boost/test/tools/context.hpp>
+#include <boost/test/unit_test.hpp>
class MockMailServerImpl : public Gentoo::MockMailServer {
public:
@@ -50,9 +50,12 @@ class DLL_PUBLIC TestClient : public IceTray::DryIceClient {
#define SQL_REQUIRE_EQUAL(sql, type, expected) BOOST_TEST_CONTEXT(sql) { sqlRequireEqual<type>(db, sql, expected); }
template<typename T>
void sqlRequireEqual(DB::ConnectionPtr db, const char * const sql, const T & expected) {
- db->select(sql)->forEachRow<T>([expected](const auto & n) {
+ int assertedRows = 0;
+ db->select(sql)->forEachRow<T>([expected,&assertedRows](const auto & n) {
BOOST_REQUIRE_EQUAL(expected, n);
+ assertedRows += 1;
});
+ BOOST_REQUIRE_EQUAL(assertedRows, 1);
}
#endif
diff --git a/gentoobrowse-api/unittests/testMaintenance.cpp b/gentoobrowse-api/unittests/testMaintenance.cpp
index 26272d1..eab8090 100644
--- a/gentoobrowse-api/unittests/testMaintenance.cpp
+++ b/gentoobrowse-api/unittests/testMaintenance.cpp
@@ -205,9 +205,9 @@ BOOST_AUTO_TEST_CASE( testRefreshGitRepository )
}
BOOST_TEST_CONTEXT("And it maintained its original packageId, but changed categoryId") {
SQL_REQUIRE_EQUAL(R"SQL(SELECT p.packageid FROM gentoobrowse.categories c, gentoobrowse.packages p
- WHERE c.categoryid = p.categoryid AND p.name = 'libkgapi' AND c.name='net-libs')SQL", int64_t, 9);
+ WHERE c.categoryid = p.categoryid AND p.name = 'libkgapi' AND c.name='kde-apps')SQL", int64_t, 9);
SQL_REQUIRE_EQUAL(R"SQL(SELECT p.categoryid FROM gentoobrowse.categories c, gentoobrowse.packages p
- WHERE c.categoryid = p.categoryid AND p.name = 'libkgapi' AND c.name='net-libs')SQL", int64_t, 8);
+ WHERE c.categoryid = p.categoryid AND p.name = 'libkgapi' AND c.name='kde-apps')SQL", int64_t, 8);
}
BOOST_TEST_CONTEXT("Original ebuilds in moved package were not deleted and replaced") {
SQL_REQUIRE_EQUAL(R"SQL(SELECT COUNT(*) FROM gentoobrowse.ebuilds e WHERE e.packageid = 9)SQL", int64_t, 2);