From e650fddc9cc554f213a850ca0a32dba5292b8637 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 10 Apr 2017 15:11:53 +0100 Subject: Fix assertions and validate row count in SQL require equal --- gentoobrowse-api/unittests/Jamfile.jam | 1 + gentoobrowse-api/unittests/mockDefs.h | 7 +++++-- gentoobrowse-api/unittests/testMaintenance.cpp | 4 ++-- 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 : ..//IceBox dryice ../service//gentoobrowse-service + boost_utf : : dbpp-postgresql ..//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 #include #include -#include +#include 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(db, sql, expected); } template void sqlRequireEqual(DB::ConnectionPtr db, const char * const sql, const T & expected) { - db->select(sql)->forEachRow([expected](const auto & n) { + int assertedRows = 0; + db->select(sql)->forEachRow([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); -- cgit v1.2.3