summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-04-24 17:26:38 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2016-04-25 21:37:32 +0100
commitdcf33912da2f30cd24f39f9854b5231e0366c8c1 (patch)
tree4fd9b253ed49e9539d699a3ae1c3c8489c05d003
parentUpdate IUSE and KEYWORDS (diff)
downloadgentoobrowse-api-dcf33912da2f30cd24f39f9854b5231e0366c8c1.tar.bz2
gentoobrowse-api-dcf33912da2f30cd24f39f9854b5231e0366c8c1.tar.xz
gentoobrowse-api-dcf33912da2f30cd24f39f9854b5231e0366c8c1.zip
Tidy up assertions
-rw-r--r--gentoobrowse-api/unittests/testMaintenance.cpp49
1 files changed, 27 insertions, 22 deletions
diff --git a/gentoobrowse-api/unittests/testMaintenance.cpp b/gentoobrowse-api/unittests/testMaintenance.cpp
index b51d599..8a3a70f 100644
--- a/gentoobrowse-api/unittests/testMaintenance.cpp
+++ b/gentoobrowse-api/unittests/testMaintenance.cpp
@@ -38,10 +38,27 @@ class SampleData {
};
#define SQL_REQUIRE_EQUAL(sql, type, expected) \
- db->select(sql)->forEachRow<type>([](const auto & n) { BOOST_REQUIRE_EQUAL(expected, n); });
+ db->select(sql)->forEachRow<type>([&expected](const auto & n) { BOOST_REQUIRE_EQUAL(expected, n); });
BOOST_FIXTURE_TEST_SUITE(tp, TestClient)
+void
+doRefreshPackageTree(SampleData & sd, DB::ConnectionPtr db, const std::string & archive, const std::string & dir,
+ Gentoo::MaintenancePrx m, int64_t files, int64_t cats, int64_t devvcs, int64_t pkgs, int64_t ebs)
+{
+ if (!archive.empty()) {
+ sd.extract(archive, dir);
+ }
+ m->refreshPackageTree();
+ sd.clean();
+
+ SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.files", int64_t, files);
+ SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.categories", int64_t, cats);
+ SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.categories WHERE name = 'dev-vcs'", int64_t, devvcs);
+ SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.packages", int64_t, pkgs);
+ SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.ebuilds", int64_t, ebs);
+}
+
BOOST_AUTO_TEST_CASE( refreshPackageTree )
{
SampleData sd;
@@ -51,39 +68,27 @@ BOOST_AUTO_TEST_CASE( refreshPackageTree )
insRepo->bindParamS(1, (treeDir / "gentoo").string());
insRepo->execute();
- sd.extract("4156eb45cf3b0ce1d7125b84efd8688c2d6e831d", "gentoo");
- m->refreshPackageTree();
- sd.clean();
+ doRefreshPackageTree(sd, db, "4156eb45cf3b0ce1d7125b84efd8688c2d6e831d", "gentoo",
+ m, 2084, 5, 1, 482, 981);
- SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.files", int64_t, 2084);
- SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.categories", int64_t, 5);
- SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.categories WHERE name = 'dev-vcs'", int64_t, 1);
- SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.packages", int64_t, 482);
- SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.ebuilds", int64_t, 981);
db->execute("COPY gentoobrowse.categories TO '/tmp/categories1.tsv'");
db->execute("COPY gentoobrowse.packages TO '/tmp/packages1.tsv'");
db->execute("COPY gentoobrowse.ebuilds TO '/tmp/ebuilds1.tsv'");
db->execute("COPY gentoobrowse.ebuild_uses TO '/tmp/ebuild_uses1.tsv'");
+ db->execute("COPY gentoobrowse.ebuild_archs TO '/tmp/ebuild_archs1.tsv'");
- sd.extract("756569aa764177340726dd3d40b41d89b11b20c7", "gentoo");
- m->refreshPackageTree();
- sd.clean();
+ doRefreshPackageTree(sd, db, "756569aa764177340726dd3d40b41d89b11b20c7", "gentoo",
+ m, 2087, 5, 1, 484, 982);
- SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.files", int64_t, 2034);
- SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.categories", int64_t, 5);
- SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.categories WHERE name = 'dev-vcs'", int64_t, 1);
- SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.packages", int64_t, 484);
- SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.ebuilds", int64_t, 982);
db->execute("COPY gentoobrowse.categories TO '/tmp/categories2.tsv'");
db->execute("COPY gentoobrowse.packages TO '/tmp/packages2.tsv'");
db->execute("COPY gentoobrowse.ebuilds TO '/tmp/ebuilds2.tsv'");
+ db->execute("COPY gentoobrowse.ebuild_uses TO '/tmp/ebuild_uses2.tsv'");
+ db->execute("COPY gentoobrowse.ebuild_archs TO '/tmp/ebuild_archs2.tsv'");
+ doRefreshPackageTree(sd, db, "", "gentoo",
+ m, 0, 0, 0, 0, 0);
m->refreshPackageTree();
-
- SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.files", int64_t, 0);
- SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.categories", int64_t, 0);
- SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.packages", int64_t, 0);
- SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.ebuilds", int64_t, 0);
}
BOOST_AUTO_TEST_SUITE_END();