aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--brep/package30
-rw-r--r--brep/package-search.cxx41
-rw-r--r--brep/package-version-search.cxx77
-rw-r--r--brep/page63
-rw-r--r--brep/page.cxx82
-rw-r--r--tests/loader/driver.cxx225
-rw-r--r--tests/loader/external/1/misc/packages8
7 files changed, 339 insertions, 187 deletions
diff --git a/brep/package b/brep/package
index c383b82..75920c4 100644
--- a/brep/package
+++ b/brep/package
@@ -463,7 +463,6 @@ namespace brep
struct max_package_version
{
using version_type = brep::version;
-
version_type version;
void
@@ -480,10 +479,33 @@ namespace brep
get() set(_id (std::move (?)))
};
- #pragma db view object(package)
- struct package_count
+ #pragma db view object(package_version = version) \
+ object(package_version = v: \
+ version::id.data.package == v::id.data.package && \
+ (version::id.data.epoch < v::id.data.epoch || \
+ (version::id.data.epoch == v::id.data.epoch && \
+ (version::id.data.canonical_upstream < \
+ v::id.data.canonical_upstream || \
+ (version::id.data.canonical_upstream == \
+ v::id.data.canonical_upstream && \
+ version::id.data.revision < v::id.data.revision))))) \
+ object(package inner: version::id.data.package == package::name && \
+ version::internal_repository.is_not_null () && \
+ v::id.data.package.is_null ())
+ struct internal_package
{
- #pragma db column("count(*)")
+ using package_type = brep::package;
+ std::shared_ptr<package_type> package;
+ std::shared_ptr<package_version> version;
+ };
+
+ #pragma db view object(package) \
+ object(package_version: package_version::id.data.package == \
+ package::name) \
+ query(package_version::internal_repository.is_not_null () && (?))
+ struct internal_package_count
+ {
+ #pragma db column("count(DISTINCT" + package::name + ")")
std::size_t count;
};
diff --git a/brep/package-search.cxx b/brep/package-search.cxx
index 02a8547..a840687 100644
--- a/brep/package-search.cxx
+++ b/brep/package-search.cxx
@@ -71,14 +71,12 @@ namespace brep
<< HEAD
<< TITLE << title << ~TITLE
<< CSS_STYLE << ident
- << pager_style () << ident
- << "a {text-decoration: none;}" << ident
- << "a:hover {text-decoration: underline;}" << ident
+ << A_STYLE () << ident
+ << PAGER_STYLE () << ident
<< ".packages {font-size: x-large;}" << ident
<< ".package {margin: 0.5em 0 0;}" << ident
<< ".name {font-size: x-large;}" << ident
- << ".tags {margin: 0.1em 0 0;}" << ident
- << ".tag {padding: 0 0.3em 0 0;}"
+ << ".dependencies {margin: 0.3em 0 0;}" << ident
<< ~CSS_STYLE
<< ~HEAD
<< BODY;
@@ -92,7 +90,7 @@ namespace brep
// @@ Query will include search criteria if specified.
//
- size_t pc (db_->query_value<package_count> ().count);
+ size_t pc (db_->query_value<internal_package_count> ().count);
s << DIV(CLASS="packages")
<< "Packages (" << pc << ")"
@@ -102,15 +100,19 @@ namespace brep
// and search index structure get implemented. Query will also
// include search criteria if specified.
//
- using query = query<package>;
+ using query = query<internal_package>;
+
auto r (
- db_->query<package> (
- "ORDER BY" + query::name +
+ db_->query<internal_package> (
+ "ORDER BY" + query::package::name +
"OFFSET" + to_string (pr.page () * rop) +
"LIMIT" + to_string (rop)));
- for (const auto& p: r)
+ for (const auto& ip: r)
{
+ const package& p = *ip.package;
+ const package_version& v = *ip.version;
+
s << DIV(CLASS="package")
<< DIV(CLASS="name")
<< A
@@ -127,17 +129,12 @@ namespace brep
<< ~DIV
<< DIV(CLASS="summary")
<< p.summary
- << ~DIV;
-
- if (!p.tags.empty ())
- {
- s << DIV(CLASS="tags");
-
- for (const auto& t: p.tags)
- s << SPAN(CLASS="tag") << t << ~SPAN << " ";
-
- s << ~DIV;
- }
+ << ~DIV
+ << DIV(CLASS="dependencies")
+ << "Dependencies: " << v.dependencies.size ()
+ << ~DIV
+ << LICENSES (v.license_alternatives)
+ << TAGS (p.tags);
s << ~DIV;
}
@@ -157,7 +154,7 @@ namespace brep
return url;
});
- s << pager (pr.page (), pc, rop, options_->pages_in_pager (), u)
+ s << PAGER (pr.page (), pc, rop, options_->pages_in_pager (), u)
<< ~BODY
<< ~HTML;
}
diff --git a/brep/package-version-search.cxx b/brep/package-version-search.cxx
index bd01a46..336650e 100644
--- a/brep/package-version-search.cxx
+++ b/brep/package-version-search.cxx
@@ -7,7 +7,6 @@
#include <string>
#include <memory> // make_shared(), shared_ptr
#include <cstddef> // size_t
-#include <cassert>
#include <xml/serializer>
@@ -71,19 +70,18 @@ namespace brep
<< HEAD
<< TITLE << title << ~TITLE
<< CSS_STYLE << ident
- << pager_style () << ident
- << "a {text-decoration: none;}" << ident
- << "a:hover {text-decoration: underline;}" << ident
+ << A_STYLE () << ident
+ << PAGER_STYLE () << ident
<< ".name {font-size: xx-large; font-weight: bold;}" << ident
<< ".summary {font-size: x-large; margin: 0.2em 0 0;}" << ident
- << ".url {font-size: small;}" << ident
- << ".email {font-size: small;}" << ident
+ << ".url {font-size: 90%;}" << ident
+ << ".email {font-size: 90%;}" << ident
<< ".description {margin: 0.5em 0 0;}" << ident
- << ".tags {margin: 0.5em 0 0;}" << ident
- << ".tag {padding: 0 0.3em 0 0;}" << ident
+ << ".tags {margin: 0.3em 0 0;}" << ident
<< ".versions {font-size: x-large; margin: 0.5em 0 0;}" << ident
<< ".package_version {margin: 0.5em 0 0;}" << ident
- << ".version {font-size: x-large;}"
+ << ".version {font-size: x-large;}" << ident
+ << ".priority {margin: 0.3em 0 0;}"
<< ~CSS_STYLE
<< ~HEAD
<< BODY;
@@ -106,9 +104,8 @@ namespace brep
<< ~DIV
<< DIV(CLASS="summary")
<< p->summary
- << ~DIV;
-
- s << DIV(CLASS="url")
+ << ~DIV
+ << DIV(CLASS="url")
<< A << HREF << p->url << ~HREF << p->url << ~A
<< ~DIV
<< DIV(CLASS="email")
@@ -120,22 +117,19 @@ namespace brep
<< *p->description
<< ~DIV;
- if (!p->tags.empty ())
- {
- s << DIV(CLASS="tags");
+ s << TAGS (p->tags);
- for (const auto& t: p->tags)
- s << SPAN(CLASS="tag") << t << ~SPAN << " ";
+ size_t pvc;
+ {
+ using query = query<package_version_count>;
- s << ~DIV;
+ // @@ Query will also include search criteria if specified.
+ //
+ pvc = db_->query_value<package_version_count> (
+ query::id.data.package == name &&
+ query::internal_repository.is_not_null ()).count;
}
- // @@ Query will also include search criteria if specified.
- //
- size_t pvc (
- db_->query_value<package_version_count> (
- query<package_version_count>::id.data.package == name).count);
-
s << DIV(CLASS="versions")
<< "Versions (" << pvc << ")"
<< ~DIV;
@@ -161,7 +155,9 @@ namespace brep
//
using query = query<package_version>;
auto r (
- db_->query<package_version> ((query::id.data.package == name) +
+ db_->query<package_version> (
+ (query::id.data.package == name &&
+ query::internal_repository.is_not_null ()) +
"ORDER BY" + query::id.data.epoch + "DESC," +
query::id.data.canonical_upstream + "DESC," +
query::id.data.revision + "DESC " +
@@ -170,11 +166,6 @@ namespace brep
for (const auto& v: r)
{
- static const strings priority_names (
- {"low", "medium", "high", "security"});
-
- assert (v.priority < priority_names.size ());
-
const string& vs (v.version.string ());
s << DIV(CLASS="package_version")
@@ -186,27 +177,11 @@ namespace brep
<< vs
<< ~A
<< ~DIV
- << DIV(CLASS="priority")
- << "Priority: " << priority_names[v.priority]
+ << PRIORITY (v.priority)
+ << DIV(CLASS="dependencies")
+ << "Dependencies: " << v.dependencies.size ()
<< ~DIV
- << DIV(CLASS="licenses")
- << "Licenses: ";
-
- for (const auto& la: v.license_alternatives)
- {
- if (&la != &v.license_alternatives[0])
- s << " or ";
-
- for (const auto& l: la)
- {
- if (&l != &la[0])
- s << ", ";
-
- s << l;
- }
- }
-
- s << ~DIV
+ << LICENSES (v.license_alternatives)
<< ~DIV;
}
@@ -226,7 +201,7 @@ namespace brep
return url;
});
- s << pager (pr.page (), pvc, rop, options_->pages_in_pager (), u)
+ s << PAGER (pr.page (), pvc, rop, options_->pages_in_pager (), u)
<< ~BODY
<< ~HTML;
}
diff --git a/brep/page b/brep/page
index 81b6da8..06f3350 100644
--- a/brep/page
+++ b/brep/page
@@ -11,19 +11,29 @@
#include <xml/forward>
+#include <brep/package>
+
namespace brep
{
// Page common building blocks.
//
- // Generates paging element block.
+ // A element default style.
+ //
+ struct A_STYLE
+ {
+ void
+ operator() (xml::serializer& s) const;
+ };
+
+ // Generates paging element.
//
- class pager
+ class PAGER
{
public:
using get_url_type = std::function<std::string(std::size_t page)>;
- pager (std::size_t current_page,
+ PAGER (std::size_t current_page,
std::size_t item_count,
std::size_t item_per_page,
std::size_t page_number_count,
@@ -40,13 +50,56 @@ namespace brep
get_url_type get_url_;
};
- // Default pager element block style.
+ // PAGER element default style.
//
- struct pager_style
+ struct PAGER_STYLE
{
void
operator() (xml::serializer& s) const;
};
+
+ // Generates package tags element.
+ //
+ class TAGS
+ {
+ public:
+ TAGS (const strings& ts): tags_ (ts) {}
+
+ void
+ operator() (xml::serializer& s) const;
+
+ private:
+ const strings& tags_;
+ };
+
+ // Generates package version license alternatives element.
+ //
+ class LICENSES
+ {
+ public:
+ LICENSES (const license_alternatives& la)
+ : license_alternatives_ (la) {}
+
+ void
+ operator() (xml::serializer& s) const;
+
+ private:
+ const license_alternatives& license_alternatives_;
+ };
+
+ // Generates package version priority element.
+ //
+ class PRIORITY
+ {
+ public:
+ PRIORITY (const priority& pr): priority_ (pr) {}
+
+ void
+ operator() (xml::serializer& s) const;
+
+ private:
+ const priority& priority_;
+ };
}
#endif // BREP_PAGE
diff --git a/brep/page.cxx b/brep/page.cxx
index 70c6d8c..ad93e7c 100644
--- a/brep/page.cxx
+++ b/brep/page.cxx
@@ -4,6 +4,7 @@
#include <brep/page>
+#include <cassert>
#include <utility> // move()
#include <algorithm> // min()
@@ -11,16 +12,28 @@
#include <web/xhtml>
+#include <brep/package>
+
using namespace std;
using namespace xml;
using namespace web::xhtml;
namespace brep
{
- // pager
+ // A_STYLE
+ //
+ void A_STYLE::
+ operator() (xml::serializer& s) const
+ {
+ const char* ident ("\n ");
+ s << "a {text-decoration: none;}" << ident
+ << "a:hover {text-decoration: underline;}";
+ }
+
+ // PAGER
//
- pager::
- pager (size_t current_page,
+ PAGER::
+ PAGER (size_t current_page,
size_t item_count,
size_t item_per_page,
size_t page_number_count,
@@ -33,7 +46,7 @@ namespace brep
{
}
- void pager::
+ void PAGER::
operator() (serializer& s) const
{
if (item_count_ == 0 || item_per_page_ == 0)
@@ -89,9 +102,9 @@ namespace brep
}
}
- // pager_style
+ // PAGER_STYLE
//
- void pager_style::
+ void PAGER_STYLE::
operator() (xml::serializer& s) const
{
const char* ident ("\n ");
@@ -100,4 +113,61 @@ namespace brep
<< ".pg-page {padding: 0 0.3em 0 0;}" << ident
<< ".pg-cpage {padding: 0 0.3em 0 0; font-weight: bold;}";
}
+
+ // LICENSES
+ //
+ void LICENSES::
+ operator() (serializer& s) const
+ {
+ s << DIV(CLASS="licenses")
+ << "Licenses: ";
+
+ for (const auto& la: license_alternatives_)
+ {
+ if (&la != &license_alternatives_[0])
+ s << " | ";
+
+ for (const auto& l: la)
+ {
+ if (&l != &la[0])
+ s << " & ";
+
+ s << l;
+ }
+ }
+
+ s << ~DIV;
+ }
+
+ // TAGS
+ //
+ void TAGS::
+ operator() (serializer& s) const
+ {
+ if (!tags_.empty ())
+ {
+ s << DIV(CLASS="tags")
+ << "Tags: ";
+
+ for (const auto& t: tags_)
+ s << t << " ";
+
+ s << ~DIV;
+ }
+ }
+
+ // PRIORITY
+ //
+ void PRIORITY::
+ operator() (serializer& s) const
+ {
+ static const strings priority_names (
+ {"low", "medium", "high", "security"});
+
+ assert (priority_ < priority_names.size ());
+
+ s << DIV(CLASS="priority")
+ << "Priority: " << priority_names[priority_]
+ << ~DIV;
+ }
}
diff --git a/tests/loader/driver.cxx b/tests/loader/driver.cxx
index 1fc2521..f8fb545 100644
--- a/tests/loader/driver.cxx
+++ b/tests/loader/driver.cxx
@@ -92,7 +92,7 @@ main (int argc, char* argv[])
assert (db.query<repository> ().size () == 3);
assert (db.query<package> ().size () == 4);
- assert (db.query<package_version> ().size () == 8);
+ assert (db.query<package_version> ().size () == 9);
shared_ptr<repository> sr (db.load<repository> ("cppget.org/stable"));
shared_ptr<repository> mr (db.load<repository> ("cppget.org/math"));
@@ -126,17 +126,7 @@ main (int argc, char* argv[])
return v1->version < v2->version;
});
- version fv0 ("1.0");
- shared_ptr<package_version> fpv0 (
- db.load<package_version> (
- package_version_id {
- "libfoo",
- fv0.epoch (),
- fv0.canonical_upstream (),
- fv0.revision ()}));
- assert (check_location (fpv0));
-
- version fv1 ("1.2.2");
+ version fv1 ("1.0");
shared_ptr<package_version> fpv1 (
db.load<package_version> (
package_version_id {
@@ -146,7 +136,7 @@ main (int argc, char* argv[])
fv1.revision ()}));
assert (check_location (fpv1));
- version fv2 ("1.2.3-4");
+ version fv2 ("1.2.2");
shared_ptr<package_version> fpv2 (
db.load<package_version> (
package_version_id {
@@ -156,7 +146,7 @@ main (int argc, char* argv[])
fv2.revision ()}));
assert (check_location (fpv2));
- version fv3 ("1.2.4");
+ version fv3 ("1.2.3-4");
shared_ptr<package_version> fpv3 (
db.load<package_version> (
package_version_id {
@@ -166,6 +156,16 @@ main (int argc, char* argv[])
fv3.revision ()}));
assert (check_location (fpv3));
+ version fv4 ("1.2.4");
+ shared_ptr<package_version> fpv4 (
+ db.load<package_version> (
+ package_version_id {
+ "libfoo",
+ fv4.epoch (),
+ fv4.canonical_upstream (),
+ fv4.revision ()}));
+ assert (check_location (fpv4));
+
version xv ("1.0.0-1");
shared_ptr<package_version> xpv (
db.load<package_version> (
@@ -241,34 +241,20 @@ main (int argc, char* argv[])
assert (pf->package_email && *pf->package_email == "pack@example.com");
auto& fpv (pf->versions);
- assert (fpv.size () == 5);
+ assert (fpv.size () == 6);
sort (fpv.begin (), fpv.end (), vc);
- assert (fpv[0].load () == fpv0);
assert (fpv[1].load () == fpv1);
assert (fpv[2].load () == fpv2);
assert (fpv[3].load () == fpv3);
+ assert (fpv[4].load () == fpv4);
// Verify libfoo package versions.
//
- assert (fpv0->internal_repository.load () == sr);
- assert (fpv0->external_repositories.size () == 1);
- assert (fpv0->external_repositories[0].load () == cr);
- assert (fpv0->package.load () == pf);
- assert (fpv0->version == version ("1.0"));
- assert (fpv0->priority == priority::low);
- assert (fpv0->changes.empty ());
-
- assert (fpv0->license_alternatives.size () == 1);
- assert (fpv0->license_alternatives[0].size () == 1);
- assert (fpv0->license_alternatives[0][0] == "MIT");
-
- assert (fpv0->dependencies.empty ());
- assert (fpv0->requirements.empty ());
-
assert (fpv1->internal_repository.load () == sr);
- assert (fpv1->external_repositories.empty ());
+ assert (fpv1->external_repositories.size () == 1);
+ assert (fpv1->external_repositories[0].load () == cr);
assert (fpv1->package.load () == pf);
- assert (fpv1->version == version ("1.2.2"));
+ assert (fpv1->version == version ("1.0"));
assert (fpv1->priority == priority::low);
assert (fpv1->changes.empty ());
@@ -276,67 +262,62 @@ main (int argc, char* argv[])
assert (fpv1->license_alternatives[0].size () == 1);
assert (fpv1->license_alternatives[0][0] == "MIT");
- assert (fpv1->dependencies.size () == 2);
- assert (fpv1->dependencies[0].size () == 1);
- assert (fpv1->dependencies[1].size () == 1);
+ assert (fpv1->dependencies.empty ());
+ assert (fpv1->requirements.empty ());
+
+ assert (fpv2->internal_repository.load () == sr);
+ assert (fpv2->external_repositories.empty ());
+ assert (fpv2->package.load () == pf);
+ assert (fpv2->version == version ("1.2.2"));
+ assert (fpv2->priority == priority::low);
+ assert (fpv2->changes.empty ());
+
+ assert (fpv2->license_alternatives.size () == 1);
+ assert (fpv2->license_alternatives[0].size () == 1);
+ assert (fpv2->license_alternatives[0][0] == "MIT");
- assert (fpv1->dependencies[0][0] ==
+ assert (fpv2->dependencies.size () == 2);
+ assert (fpv2->dependencies[0].size () == 1);
+ assert (fpv2->dependencies[1].size () == 1);
+
+ assert (fpv2->dependencies[0][0] ==
(dependency {
"libbar",
brep::optional<version_comparison> (
version_comparison{version ("2.4.0"), comparison::le})}));
- assert (fpv1->dependencies[1][0] ==
+ assert (fpv2->dependencies[1][0] ==
(dependency {
"libexp",
brep::optional<version_comparison> (
version_comparison{version ("1+1.2"), comparison::eq})}));
- requirements& fpvr1 (fpv1->requirements);
- assert (fpvr1.size () == 4);
+ requirements& fpvr2 (fpv2->requirements);
+ assert (fpvr2.size () == 4);
- assert (fpvr1[0] == strings ({"linux", "windows", "macosx"}));
- assert (!fpvr1[0].conditional);
- assert (fpvr1[0].comment.empty ());
+ assert (fpvr2[0] == strings ({"linux", "windows", "macosx"}));
+ assert (!fpvr2[0].conditional);
+ assert (fpvr2[0].comment.empty ());
- assert (fpvr1[1] == strings ({"c++11"}));
- assert (!fpvr1[1].conditional);
- assert (fpvr1[1].comment.empty ());
+ assert (fpvr2[1] == strings ({"c++11"}));
+ assert (!fpvr2[1].conditional);
+ assert (fpvr2[1].comment.empty ());
- assert (fpvr1[2].empty ());
- assert (fpvr1[2].conditional);
- assert (fpvr1[2].comment == "VC++ 12.0 or later if targeting Windows.");
+ assert (fpvr2[2].empty ());
+ assert (fpvr2[2].conditional);
+ assert (fpvr2[2].comment == "VC++ 12.0 or later if targeting Windows.");
- assert (fpvr1[3].empty ());
- assert (fpvr1[3].conditional);
- assert (fpvr1[3].comment ==
+ assert (fpvr2[3].empty ());
+ assert (fpvr2[3].conditional);
+ assert (fpvr2[3].comment ==
"libc++ standard library if using Clang on Mac OS X.");
- assert (fpv2->internal_repository.load () == sr);
- assert (fpv2->external_repositories.empty ());
- assert (fpv2->package.load () == pf);
- assert (fpv2->version == version ("1.2.3-4"));
- assert (fpv2->priority == priority::low);
- assert (fpv2->changes.empty ());
-
- assert (fpv2->license_alternatives.size () == 1);
- assert (fpv2->license_alternatives[0].size () == 1);
- assert (fpv2->license_alternatives[0][0] == "MIT");
-
- assert (fpv2->dependencies.size () == 1);
- assert (fpv2->dependencies[0].size () == 1);
- assert (fpv2->dependencies[0][0] ==
- (dependency {
- "libmisc",
- brep::optional<version_comparison> (
- version_comparison{version ("2.0.0"), comparison::ge})}));
-
assert (fpv3->internal_repository.load () == sr);
assert (fpv3->external_repositories.empty ());
assert (fpv3->package.load () == pf);
- assert (fpv3->version == version ("1.2.4"));
+ assert (fpv3->version == version ("1.2.3-4"));
assert (fpv3->priority == priority::low);
- assert (fpv3->changes == "some changes 1\nsome changes 2");
+ assert (fpv3->changes.empty ());
assert (fpv3->license_alternatives.size () == 1);
assert (fpv3->license_alternatives[0].size () == 1);
@@ -350,6 +331,25 @@ main (int argc, char* argv[])
brep::optional<version_comparison> (
version_comparison{version ("2.0.0"), comparison::ge})}));
+ assert (fpv4->internal_repository.load () == sr);
+ assert (fpv4->external_repositories.empty ());
+ assert (fpv4->package.load () == pf);
+ assert (fpv4->version == version ("1.2.4"));
+ assert (fpv4->priority == priority::low);
+ assert (fpv4->changes == "some changes 1\nsome changes 2");
+
+ assert (fpv4->license_alternatives.size () == 1);
+ assert (fpv4->license_alternatives[0].size () == 1);
+ assert (fpv4->license_alternatives[0][0] == "MIT");
+
+ assert (fpv4->dependencies.size () == 1);
+ assert (fpv4->dependencies[0].size () == 1);
+ assert (fpv4->dependencies[0][0] ==
+ (dependency {
+ "libmisc",
+ brep::optional<version_comparison> (
+ version_comparison{version ("2.0.0"), comparison::ge})}));
+
// Verify 'math' repository.
//
assert (mr->location.canonical_name () == "cppget.org/math");
@@ -376,47 +376,47 @@ main (int argc, char* argv[])
ev.revision ()}));
assert (check_location (epv));
- version fv4 ("1.2.4-1");
- shared_ptr<package_version> fpv4 (
+ version fv5 ("1.2.4-1");
+ shared_ptr<package_version> fpv5 (
db.load<package_version> (
package_version_id {
"libfoo",
- fv4.epoch (),
- fv4.canonical_upstream (),
- fv4.revision ()}));
- assert (fpv[4].load () == fpv4);
- assert (check_location (fpv4));
+ fv5.epoch (),
+ fv5.canonical_upstream (),
+ fv5.revision ()}));
+ assert (fpv[5].load () == fpv5);
+ assert (check_location (fpv5));
// Verify libfoo package versions.
//
- assert (fpv4->internal_repository.load () == mr);
- assert (fpv4->external_repositories.empty ());
- assert (fpv4->package.load () == pf);
- assert (fpv4->version == version ("1.2.4-1"));
- assert (fpv4->priority == priority::high);
- assert (fpv4->changes.empty ());
-
- assert (fpv4->license_alternatives.size () == 2);
- assert (fpv4->license_alternatives[0].comment ==
+ assert (fpv5->internal_repository.load () == mr);
+ assert (fpv5->external_repositories.empty ());
+ assert (fpv5->package.load () == pf);
+ assert (fpv5->version == version ("1.2.4-1"));
+ assert (fpv5->priority == priority::high);
+ assert (fpv5->changes.empty ());
+
+ assert (fpv5->license_alternatives.size () == 2);
+ assert (fpv5->license_alternatives[0].comment ==
"If using with GNU TLS.");
- assert (fpv4->license_alternatives[0].size () == 2);
- assert (fpv4->license_alternatives[0][0] == "LGPLv2");
- assert (fpv4->license_alternatives[0][1] == "MIT");
- assert (fpv4->license_alternatives[1].comment ==
+ assert (fpv5->license_alternatives[0].size () == 2);
+ assert (fpv5->license_alternatives[0][0] == "LGPLv2");
+ assert (fpv5->license_alternatives[0][1] == "MIT");
+ assert (fpv5->license_alternatives[1].comment ==
"If using with OpenSSL.");
- assert (fpv4->license_alternatives[1].size () == 1);
- assert (fpv4->license_alternatives[1][0] == "BSD");
+ assert (fpv5->license_alternatives[1].size () == 1);
+ assert (fpv5->license_alternatives[1][0] == "BSD");
- assert (fpv4->dependencies.size () == 1);
- assert (fpv4->dependencies[0].size () == 1);
+ assert (fpv5->dependencies.size () == 1);
+ assert (fpv5->dependencies[0].size () == 1);
- assert (fpv4->dependencies[0][0] ==
+ assert (fpv5->dependencies[0][0] ==
(dependency {
"libmisc",
brep::optional<version_comparison> (
version_comparison{version ("2.3.0"), comparison::ge})}));
- assert (fpv4->requirements.empty ());
+ assert (fpv5->requirements.empty ());
// Verify libexp package.
//
@@ -479,6 +479,16 @@ main (int argc, char* argv[])
bv.revision ()}));
assert (check_location (bpv));
+ version fv0 ("0.1");
+ shared_ptr<package_version> fpv0 (
+ db.load<package_version> (
+ package_version_id {
+ "libfoo",
+ fv0.epoch (),
+ fv0.canonical_upstream (),
+ fv0.revision ()}));
+ assert (check_location (fpv0));
+
// Verify libbar package.
//
shared_ptr<package> pb (db.load<package> ("libbar"));
@@ -514,6 +524,23 @@ main (int argc, char* argv[])
assert (bpv->dependencies.empty ());
assert (bpv->requirements.empty ());
+ // Verify libfoo package versions.
+ //
+ assert (fpv0->internal_repository.load () == nullptr);
+ assert (fpv0->external_repositories.size () == 1);
+ assert (fpv0->external_repositories[0].load () == cr);
+ assert (fpv0->package.load () == pf);
+ assert (fpv0->version == version ("0.1"));
+ assert (fpv0->priority == priority::low);
+ assert (fpv0->changes.empty ());
+
+ assert (fpv0->license_alternatives.size () == 1);
+ assert (fpv0->license_alternatives[0].size () == 1);
+ assert (fpv0->license_alternatives[0][0] == "MIT");
+
+ assert (fpv0->dependencies.empty ());
+ assert (fpv0->requirements.empty ());
+
// Update package summary, update package persistent state, rerun loader
// and ensure the model were not rebuilt.
//
diff --git a/tests/loader/external/1/misc/packages b/tests/loader/external/1/misc/packages
index d6d34ea..843408b 100644
--- a/tests/loader/external/1/misc/packages
+++ b/tests/loader/external/1/misc/packages
@@ -21,3 +21,11 @@ license: MIT
url: http://www.example.com/foo/
email: foo-users@example.com
location: libfoo-1.0.tar.gz
+:
+name: libfoo
+version: 0.1
+summary: Foo
+license: MIT
+url: http://www.example.com/foo/
+email: foo-users@example.com
+location: libfoo-0.1.tar.gz