From 8355e7561cc7bcaf92e32226e9d65eb4dc1ee27a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 15 Oct 2016 12:41:47 +0100 Subject: Only dump DB when asked for --- gentoobrowse-api/unittests/testMaintenance.cpp | 54 ++++++++++++-------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/gentoobrowse-api/unittests/testMaintenance.cpp b/gentoobrowse-api/unittests/testMaintenance.cpp index dc4c92b..a845b7c 100644 --- a/gentoobrowse-api/unittests/testMaintenance.cpp +++ b/gentoobrowse-api/unittests/testMaintenance.cpp @@ -66,6 +66,29 @@ doRefreshPackageTree(SampleData & sd, DB::ConnectionPtr db, const std::string & SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.news", int64_t, news); } +void +dumpDb(DB::ConnectionPtr db) +{ +#if DUMBDB + db->execute("COPY gentoobrowse.files TO '/tmp/files.tsv'"); + db->execute("COPY gentoobrowse.categories TO '/tmp/categories.tsv'"); + db->execute("COPY gentoobrowse.packages TO '/tmp/packages.tsv'"); + db->execute("COPY gentoobrowse.ebuilds TO '/tmp/ebuilds.tsv'"); + db->execute("COPY gentoobrowse.ebuild_uses TO '/tmp/ebuild_uses.tsv'"); + db->execute("COPY gentoobrowse.ebuild_archs TO '/tmp/ebuild_archs.tsv'"); + db->execute("COPY gentoobrowse.package_urls TO '/tmp/package_urls.tsv'"); + db->execute("COPY gentoobrowse.use_global TO '/tmp/use_global.tsv'"); + db->execute("COPY gentoobrowse.use_local TO '/tmp/use_local.tsv'"); + db->execute("COPY gentoobrowse.use_groups TO '/tmp/use_groups.tsv'"); + db->execute("COPY gentoobrowse.use_group TO '/tmp/use_group.tsv'"); + db->execute("COPY gentoobrowse.masksets TO '/tmp/masksets.tsv'"); + db->execute("COPY gentoobrowse.ebuild_masks TO '/tmp/ebuild_masks.tsv'"); + db->execute("COPY gentoobrowse.news TO '/tmp/news.tsv'"); +#else + (void)db; +#endif +} + BOOST_AUTO_TEST_CASE( refreshPackageTree ) { SampleData sd; @@ -77,38 +100,11 @@ BOOST_AUTO_TEST_CASE( refreshPackageTree ) doRefreshPackageTree(sd, db, "4156eb45cf3b0ce1d7125b84efd8688c2d6e831d", "gentoo", m, 2084, 5, 1, 482, 981, 3626, 4593, 501, 393, 238, 50, 1573, 2008, 1543, 81); - - db->execute("COPY gentoobrowse.files TO '/tmp/files1.tsv'"); - 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'"); - db->execute("COPY gentoobrowse.package_urls TO '/tmp/package_urls1.tsv'"); - db->execute("COPY gentoobrowse.use_global TO '/tmp/use_global1.tsv'"); - db->execute("COPY gentoobrowse.use_local TO '/tmp/use_local1.tsv'"); - db->execute("COPY gentoobrowse.use_groups TO '/tmp/use_groups1.tsv'"); - db->execute("COPY gentoobrowse.use_group TO '/tmp/use_group1.tsv'"); - db->execute("COPY gentoobrowse.masksets TO '/tmp/masksets1.tsv'"); - db->execute("COPY gentoobrowse.ebuild_masks TO '/tmp/ebuild_masks1.tsv'"); - db->execute("COPY gentoobrowse.news TO '/tmp/news1.tsv'"); + dumpDb(db); doRefreshPackageTree(sd, db, "756569aa764177340726dd3d40b41d89b11b20c7", "gentoo", m, 2087, 5, 1, 484, 982, 3638, 4599, 503, 393, 238, 50, 1573, 2009, 1546, 79); - - 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'"); - db->execute("COPY gentoobrowse.package_urls TO '/tmp/package_urls2.tsv'"); - db->execute("COPY gentoobrowse.use_global TO '/tmp/use_global2.tsv'"); - db->execute("COPY gentoobrowse.use_local TO '/tmp/use_local2.tsv'"); - db->execute("COPY gentoobrowse.use_groups TO '/tmp/use_groups2.tsv'"); - db->execute("COPY gentoobrowse.use_group TO '/tmp/use_group2.tsv'"); - db->execute("COPY gentoobrowse.masksets TO '/tmp/masksets2.tsv'"); - db->execute("COPY gentoobrowse.ebuild_masks TO '/tmp/ebuild_masks2.tsv'"); - db->execute("COPY gentoobrowse.news TO '/tmp/news2.tsv'"); + dumpDb(db); doRefreshPackageTree(sd, db, "", "gentoo", m, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); -- cgit v1.2.3