summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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();