diff options
| -rw-r--r-- | Jamroot.jam | 5 | ||||
| -rw-r--r-- | gentoobrowse-api/unittests/testMaintenance.cpp | 47 | 
2 files changed, 37 insertions, 15 deletions
diff --git a/Jamroot.jam b/Jamroot.jam index 3ddb43d..8a29f49 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -37,10 +37,15 @@ project  		<toolset>tidy:<define>ICE_MEMBER_IMPORT_EXPORT  		<toolset>tidy:<exclude>users.cpp  		<toolset>tidy:<exclude>user-models.cpp +		<toolset>tidy:<exclude>slicer-user-models.cpp  		<toolset>tidy:<exclude>news-models.cpp +		<toolset>tidy:<exclude>slicer-news-models.cpp  		<toolset>tidy:<exclude>extended-models.cpp +		<toolset>tidy:<exclude>slicer-extended-models.cpp  		<toolset>tidy:<exclude>portage-models.cpp +		<toolset>tidy:<exclude>slicer-portage-models.cpp  		<toolset>tidy:<exclude>portage.cpp +		<toolset>tidy:<exclude>gb-base.cpp  		<toolset>tidy:<exclude>maintenance.h  		<toolset>tidy:<exclude>maintenance.cpp  		<toolset>tidy:<exclude>notifications.h diff --git a/gentoobrowse-api/unittests/testMaintenance.cpp b/gentoobrowse-api/unittests/testMaintenance.cpp index 0dc09c0..6b1621c 100644 --- a/gentoobrowse-api/unittests/testMaintenance.cpp +++ b/gentoobrowse-api/unittests/testMaintenance.cpp @@ -1,15 +1,37 @@  #define BOOST_TEST_MODULE TestMaintenance  #include <boost/test/unit_test.hpp> +#include "changeSet.h" +#include "maintenance.h" +#include "maintenance/abstractFileProcessor.h"  #include "mockDefs.h" -#include <buffer.h> +#include "portage-models.h" +#include "portage.h" +#include <Ice/Current.h> +#include <Ice/Optional.h> +#include <array> +#include <connection.h> +#include <connectionPool.h> +#include <connection_fwd.h> +#include <cstddef> +#include <cstdint>  #include <definedDirs.h> +#include <ext/alloc_traits.h> +#include <filesystem>  #include <fstream>  #include <git2.h>  #include <maintenanceimpl.h> +#include <map> +#include <memory> +#include <mockDatabase.h>  #include <mockPool.h>  #include <modifycommand.h>  #include <portageimpl.h> +#include <string> +#include <utility> +#include <vector> +// IWYU pragma: no_include <boost/type_index/type_index_facade.hpp> +// IWYU pragma: no_include "resourcePool.impl.h"  class MaintenanceClientCombined : public Maintenance, public TestClient {  }; @@ -19,15 +41,18 @@ BOOST_FIXTURE_TEST_SUITE(maintenance, MaintenanceClientCombined)  const std::filesystem::path treeDir(binDir / "tree");  const std::filesystem::path fixturesDir(rootDir / "fixtures"); +#if DUMPDB  static void dumpDb(const DB::ConnectionPtr & db); +#endif  void  doRefreshPackageTree(const DB::ConnectionPtr & db, int64_t cats, int64_t devvcs, int64_t pkgs, int64_t ebs,  		int64_t ebus, int64_t ebas, int64_t pus, int64_t ug, int64_t ul, int64_t ugs, int64_t ugds, int64_t deps,  		int64_t rdeps, int64_t news, int64_t masks, int64_t ebuildMasks)  { +#if DUMPDB  	dumpDb(db); - +#endif  	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); @@ -46,10 +71,10 @@ doRefreshPackageTree(const DB::ConnectionPtr & db, int64_t cats, int64_t devvcs,  	SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.ebuild_masks", int64_t, ebuildMasks);  } +#if DUMPDB  void  dumpDb(const DB::ConnectionPtr & db)  { -#if DUMPDB  	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'"); @@ -63,10 +88,8 @@ dumpDb(const DB::ConnectionPtr & db)  	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  } +#endif  class M2 : public Gentoo::Service::Maintenance {  public: @@ -275,15 +298,9 @@ BOOST_AUTO_TEST_CASE(testUpdateGitRepository)  	BOOST_REQUIRE(std::filesystem::is_regular_file(testRepo / "net-misc" / "gentoobrowse-api" / "Manifest"));  } -struct localPortageRepoIsComplete { -	boost::test_tools::assertion_result -	operator()(boost::unit_test::test_unit_id) const -	{ -		return !std::filesystem::exists("/usr/portage/.git/shallow"); -	} -}; - -BOOST_AUTO_TEST_CASE(testRefreshGitRepository, *boost::unit_test::precondition(localPortageRepoIsComplete {})) +BOOST_AUTO_TEST_CASE(testRefreshGitRepository, *boost::unit_test::precondition([](auto) { +	return !std::filesystem::exists("/usr/portage/.git/shallow"); +}))  {  	auto db = DB::MockDatabase::openConnectionTo("GentooBrowseAPI");  	auto insRepo = db->modify(  | 
