summaryrefslogtreecommitdiff
path: root/gentoobrowse-api/unittests/testMaintenance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gentoobrowse-api/unittests/testMaintenance.cpp')
-rw-r--r--gentoobrowse-api/unittests/testMaintenance.cpp45
1 files changed, 42 insertions, 3 deletions
diff --git a/gentoobrowse-api/unittests/testMaintenance.cpp b/gentoobrowse-api/unittests/testMaintenance.cpp
index 383f6cc..38fb258 100644
--- a/gentoobrowse-api/unittests/testMaintenance.cpp
+++ b/gentoobrowse-api/unittests/testMaintenance.cpp
@@ -3,17 +3,56 @@
#include <selectcommandUtil.impl.h>
#include "mockDefs.h"
+#include <definedDirs.h>
+#include <buffer.h>
+#include <modifycommand.h>
-BOOST_GLOBAL_FIXTURE( Service );
+BOOST_GLOBAL_FIXTURE( Maintenance );
+
+const boost::filesystem::path treeDir(binDir / "tree" / "gentoobrowse");
+const boost::filesystem::path fixturesDir(rootDir / "fixtures");
+
+class SampleData {
+ public:
+ SampleData()
+ {
+ clean();
+ }
+
+ ~SampleData()
+ {
+ clean();
+ }
+
+ void clean()
+ {
+ BOOST_TEST_CHECKPOINT("Cleaning sample data dir " << treeDir);
+ boost::filesystem::remove_all(treeDir);
+ }
+
+ void extract(const std::string & archive, const std::string & repo)
+ {
+ boost::filesystem::create_directories(treeDir);
+ boost::filesystem::create_symlink(fixturesDir / archive, treeDir / repo);
+ }
+};
BOOST_FIXTURE_TEST_SUITE(tp, TestClient)
BOOST_AUTO_TEST_CASE( refreshPackageTree )
{
- m->refreshPackageTree();
+ SampleData sd;
+ sd.extract("4156eb45cf3b0ce1d7125b84efd8688c2d6e831d", "gentoo");
auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("GentooBrowseAPI"));
+ auto insRepo = db->modify("INSERT INTO gentoobrowse.repos(name, path) VALUES(?, ?)");
+ insRepo->bindParamS(0, "gentoo");
+ insRepo->bindParamS(1, (treeDir / "gentoo").string());
+ insRepo->execute();
+
+ m->refreshPackageTree();
+
db->select("SELECT COUNT(*) FROM gentoobrowse.files")->forEachRow<int64_t>([](auto n) {
- BOOST_REQUIRE_EQUAL(96645, n);
+ BOOST_REQUIRE_EQUAL(2084, n);
});
}