aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-07 11:49:46 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-07 11:49:46 +0000
commit5fadf331969198bfd7004bab9df672641e7b85ed (patch)
tree10fe403242f2c14bc2885f261bf3ffeb8da00a4b
parentbb7d5be03a7085fcb47aa5a1d2e609dc67b082c6 (diff)
downloadpaludis-5fadf331969198bfd7004bab9df672641e7b85ed.tar.gz
paludis-5fadf331969198bfd7004bab9df672641e7b85ed.tar.xz
More portage repository tests
-rw-r--r--paludis/portage_repository_TEST.cc61
-rwxr-xr-xpaludis/portage_repository_TEST_setup.sh31
2 files changed, 87 insertions, 5 deletions
diff --git a/paludis/portage_repository_TEST.cc b/paludis/portage_repository_TEST.cc
index 9fb1482..24474c1 100644
--- a/paludis/portage_repository_TEST.cc
+++ b/paludis/portage_repository_TEST.cc
@@ -43,7 +43,7 @@ namespace test_cases
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"));
+ keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo1/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");
@@ -60,7 +60,7 @@ namespace test_cases
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"));
+ keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo2/profiles/profile"));
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
TEST_CHECK(0 == repo->name().data().substr(
@@ -78,7 +78,7 @@ namespace test_cases
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"));
+ keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo3/profiles/profile"));
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
TEST_CHECK(0 == repo->name().data().substr(
@@ -96,7 +96,7 @@ namespace test_cases
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"));
+ keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo1/profiles/profile"));
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
@@ -106,7 +106,58 @@ namespace test_cases
TEST_CHECK(! repo->has_category_named(CategoryNamePart("cat-four")));
}
} test_portage_repository_has_category_named;
-}
+ struct PortageRepositoryCategoryNamesTest : TestCase
+ {
+ PortageRepositoryCategoryNamesTest() : TestCase("category names") { }
+
+ 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/repo1/profiles/profile"));
+ PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
+ &env, env.package_database().raw_pointer(), keys));
+
+ CategoryNamePartCollection::ConstPointer c(repo->category_names());
+ TEST_CHECK(c->end() != c->find(CategoryNamePart("cat-one")));
+ TEST_CHECK(c->end() != c->find(CategoryNamePart("cat-two")));
+ TEST_CHECK(c->end() != c->find(CategoryNamePart("cat-three")));
+ TEST_CHECK(c->end() == c->find(CategoryNamePart("cat-four")));
+ TEST_CHECK_EQUAL(3, std::distance(c->begin(), c->end()));
+ }
+ } test_portage_repository_category_names;
+
+ struct PortageRepositoryHasPackageNamedTest : TestCase
+ {
+ PortageRepositoryHasPackageNamedTest() : TestCase("has package 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/repo4"));
+ keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo4/profiles/profile"));
+ PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
+ &env, env.package_database().raw_pointer(), keys));
+
+ TEST_CHECK(repo->has_package_named(QualifiedPackageName("cat-one/pkg-one")));
+ TEST_CHECK(repo->has_package_named(QualifiedPackageName("cat-two/pkg-two")));
+ TEST_CHECK(! repo->has_package_named(QualifiedPackageName("cat-one/pkg-two")));
+ TEST_CHECK(! repo->has_package_named(QualifiedPackageName("cat-two/pkg-one")));
+ TEST_CHECK(repo->has_package_named(QualifiedPackageName("cat-one/pkg-both")));
+ TEST_CHECK(repo->has_package_named(QualifiedPackageName("cat-two/pkg-both")));
+ TEST_CHECK(! repo->has_package_named(QualifiedPackageName("cat-one/pkg-neither")));
+ TEST_CHECK(! repo->has_package_named(QualifiedPackageName("cat-two/pkg-neither")));
+ TEST_CHECK(! repo->has_package_named(QualifiedPackageName("cat-three/pkg-one")));
+ TEST_CHECK(! repo->has_package_named(QualifiedPackageName("cat-three/pkg-two")));
+ TEST_CHECK(! repo->has_package_named(QualifiedPackageName("cat-three/pkg-both")));
+ TEST_CHECK(! repo->has_package_named(QualifiedPackageName("cat-three/pkg-neither")));
+ }
+ } test_portage_repository_has_package_named;
+
+}
diff --git a/paludis/portage_repository_TEST_setup.sh b/paludis/portage_repository_TEST_setup.sh
index 1a902fe..eccb9b5 100755
--- a/paludis/portage_repository_TEST_setup.sh
+++ b/paludis/portage_repository_TEST_setup.sh
@@ -12,12 +12,18 @@ cat-one
cat-two
cat-three
END
+cat <<END > profiles/profile/make.defaults
+ARCH=test
+END
cd ..
mkdir -p repo2/{eclass,distfiles,profiles/profile} || exit 1
cd repo2 || exit 1
cat <<END > profiles/categories || exit 1
END
+cat <<END > profiles/profile/make.defaults
+ARCH=test
+END
cd ..
@@ -26,6 +32,31 @@ cd repo3 || exit 1
echo "# test-repo-3" > profiles/repo_name || exit 1
cat <<END > profiles/categories || exit 1
END
+cat <<END > profiles/profile/make.defaults
+ARCH=test
+END
+cd ..
+
+
+mkdir -p repo4/{eclass,distfiles,profiles/profile} || exit 1
+mkdir -p repo4/{cat-one/{pkg-one,pkg-both},cat-two/{pkg-two,pkg-both}} || exit 1
+cd repo4 || exit 1
+echo "test-repo-4" > profiles/repo_name || exit 1
+cat <<END > profiles/categories || exit 1
+cat-one
+cat-two
+END
+cat <<END > profiles/profile/make.defaults
+ARCH=test
+END
+cat <<END > cat-one/pkg-one/pkg-one-1.ebuild || exit 1
+END
+cat <<END > cat-one/pkg-both/pkg-both-1.ebuild || exit 1
+END
+cat <<END > cat-two/pkg-two/pkg-two-1.ebuild || exit 1
+END
+cat <<END > cat-two/pkg-both/pkg-both-1.ebuild || exit 1
+END
cd ..