aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-07 10:44:13 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-07 10:44:13 +0000
commitbb7d5be03a7085fcb47aa5a1d2e609dc67b082c6 (patch)
tree03961a22302444f3c82ba15b85574cec3b759cb7
parentf918c0a9707c6f8f77783535cdeb05094c24c98a (diff)
downloadpaludis-bb7d5be03a7085fcb47aa5a1d2e609dc67b082c6.tar.gz
paludis-bb7d5be03a7085fcb47aa5a1d2e609dc67b082c6.tar.xz
Start some tests for portage repository
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/portage_repository_TEST.cc112
-rwxr-xr-xpaludis/portage_repository_TEST_cleanup.sh10
-rwxr-xr-xpaludis/portage_repository_TEST_setup.sh31
4 files changed, 154 insertions, 1 deletions
diff --git a/paludis/files.m4 b/paludis/files.m4
index e24845e..a1480d6 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -27,7 +27,7 @@ add(`match_package', `hh', `cc')
add(`name', `hh', `cc', `test')
add(`package_database', `hh', `cc', `test')
add(`paludis', `hh', `cc')
-add(`portage_repository', `hh', `cc')
+add(`portage_repository', `hh', `cc', `test', `testscript')
add(`repository', `hh', `cc')
add(`syncer', `hh', `cc')
add(`test_environment', `hh', `cc')
diff --git a/paludis/portage_repository_TEST.cc b/paludis/portage_repository_TEST.cc
new file mode 100644
index 0000000..9fb1482
--- /dev/null
+++ b/paludis/portage_repository_TEST.cc
@@ -0,0 +1,112 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/portage_repository.hh>
+#include <paludis/test_environment.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace test;
+using namespace paludis;
+
+/** \file
+ * Test cases for PortageRepository.
+ *
+ * \ingroup Test
+ */
+
+namespace test_cases
+{
+ struct PortageRepositoryRepoNameTest : TestCase
+ {
+ PortageRepositoryRepoNameTest() : TestCase("repo name") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ std::map<std::string, std::string> keys;
+ keys.insert(std::make_pair("format", "portage"));
+ keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo1"));
+ keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/profiles/profile"));
+ PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
+ &env, env.package_database().raw_pointer(), keys));
+ TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "test-repo-1");
+ }
+ } test_portage_repository_repo_name;
+
+ struct PortageRepositoryNoRepoNameTest : TestCase
+ {
+ PortageRepositoryNoRepoNameTest() : TestCase("no repo name") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ std::map<std::string, std::string> keys;
+ keys.insert(std::make_pair("format", "portage"));
+ keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo2"));
+ keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/profiles/profile"));
+ PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
+ &env, env.package_database().raw_pointer(), keys));
+ TEST_CHECK(0 == repo->name().data().substr(
+ repo->name().data().length() - 33).compare("portage_repository_TEST_dir-repo2"));
+ }
+ } test_portage_repository_no_repo_name;
+
+ struct PortageRepositoryEmptyRepoNameTest : TestCase
+ {
+ PortageRepositoryEmptyRepoNameTest() : TestCase("empty repo name") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ std::map<std::string, std::string> keys;
+ keys.insert(std::make_pair("format", "portage"));
+ keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo3"));
+ keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/profiles/profile"));
+ PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
+ &env, env.package_database().raw_pointer(), keys));
+ TEST_CHECK(0 == repo->name().data().substr(
+ repo->name().data().length() - 33).compare("portage_repository_TEST_dir-repo3"));
+ }
+ } test_portage_repository_empty_repo_name;
+
+ struct PortageRepositoryHasCategoryNamedTest : TestCase
+ {
+ PortageRepositoryHasCategoryNamedTest() : TestCase("has category named") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ std::map<std::string, std::string> keys;
+ keys.insert(std::make_pair("format", "portage"));
+ keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo1"));
+ keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/profiles/profile"));
+ PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
+ &env, env.package_database().raw_pointer(), keys));
+
+ TEST_CHECK(repo->has_category_named(CategoryNamePart("cat-one")));
+ TEST_CHECK(repo->has_category_named(CategoryNamePart("cat-two")));
+ TEST_CHECK(repo->has_category_named(CategoryNamePart("cat-three")));
+ TEST_CHECK(! repo->has_category_named(CategoryNamePart("cat-four")));
+ }
+ } test_portage_repository_has_category_named;
+}
+
+
+
diff --git a/paludis/portage_repository_TEST_cleanup.sh b/paludis/portage_repository_TEST_cleanup.sh
new file mode 100755
index 0000000..e45cd73
--- /dev/null
+++ b/paludis/portage_repository_TEST_cleanup.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d portage_repository_TEST_dir ] ; then
+ rm -fr portage_repository_TEST_dir
+else
+ true
+fi
+
+
diff --git a/paludis/portage_repository_TEST_setup.sh b/paludis/portage_repository_TEST_setup.sh
new file mode 100755
index 0000000..1a902fe
--- /dev/null
+++ b/paludis/portage_repository_TEST_setup.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir portage_repository_TEST_dir || exit 1
+cd portage_repository_TEST_dir || exit 1
+
+mkdir -p repo1/{eclass,distfiles,profiles/profile} || exit 1
+cd repo1 || exit 1
+echo "test-repo-1" > profiles/repo_name || exit 1
+cat <<END > profiles/categories || exit 1
+cat-one
+cat-two
+cat-three
+END
+cd ..
+
+mkdir -p repo2/{eclass,distfiles,profiles/profile} || exit 1
+cd repo2 || exit 1
+cat <<END > profiles/categories || exit 1
+END
+cd ..
+
+
+mkdir -p repo3/{eclass,distfiles,profiles/profile} || exit 1
+cd repo3 || exit 1
+echo "# test-repo-3" > profiles/repo_name || exit 1
+cat <<END > profiles/categories || exit 1
+END
+cd ..
+
+