aboutsummaryrefslogtreecommitdiff
path: root/tests/repository-location
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-11-14 13:28:26 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-11-16 14:38:01 +0300
commit39c4230a41cdda3ba47ce1bb70cd2780d9da988d (patch)
treeb1342cea86fdc3cf197dd1e41d03065a019075a2 /tests/repository-location
parent3b064176e467f690a94544d511be2fe57a8f48c4 (diff)
Add support for repository typed URLs (git+https://..., etc)
Diffstat (limited to 'tests/repository-location')
-rw-r--r--tests/repository-location/driver.cxx62
1 files changed, 50 insertions, 12 deletions
diff --git a/tests/repository-location/driver.cxx b/tests/repository-location/driver.cxx
index c2153ff..3f03a5d 100644
--- a/tests/repository-location/driver.cxx
+++ b/tests/repository-location/driver.cxx
@@ -55,6 +55,26 @@ namespace bpkg
}
}
+ inline static repository_location
+ typed_loc (const string& u, optional<repository_type> t = nullopt)
+ {
+ return repository_location (u, t);
+ }
+
+ inline static bool
+ bad_typed_loc (const string& u, optional<repository_type> t = nullopt)
+ {
+ try
+ {
+ repository_location bl (u, t);
+ return false;
+ }
+ catch (const invalid_argument&)
+ {
+ return true;
+ }
+ }
+
inline static bool
bad_loc (const string& l,
const repository_location& b,
@@ -207,6 +227,16 @@ namespace bpkg
//
assert (bad_loc ("http://example.com/dir", repository_type::dir));
+ // Invalid typed repository location.
+ //
+ assert (bad_typed_loc ("")); // Empty.
+ assert (bad_typed_loc ("abc+http://example.com/repo")); // Relative.
+
+ assert (bad_typed_loc ("git+http://example.com/repo", // Types mismatch.
+ repository_type::pkg));
+
+ assert (bad_typed_loc ("http://example.com/repo")); // Invalid for pkg.
+
// Invalid web interface URL.
//
assert (bad_url (".a/..", loc ("http://stable.cppget.org/1/misc")));
@@ -313,28 +343,28 @@ namespace bpkg
{
repository_location l (loc ("file:/git/repo#branch",
repository_type::git));
- assert (l.string () == "file:/git/repo#branch");
+ assert (l.string () == "git+file:/git/repo#branch");
assert (l.canonical_name () == "git:/git/repo#branch");
}
{
repository_location l (loc ("/git/repo#branch", repository_type::git));
- assert (l.string () == "file:/git/repo#branch");
+ assert (l.string () == "git+file:/git/repo#branch");
assert (l.canonical_name () == "git:/git/repo#branch");
}
{
repository_location l (loc ("file://localhost/", repository_type::git));
- assert (l.string () == "/");
+ assert (l.string () == "git+file:///");
assert (l.canonical_name () == "git:/");
}
{
repository_location l (loc ("file://localhost/#master",
repository_type::git));
- assert (l.string () == "file:/#master");
+ assert (l.string () == "git+file:/#master");
assert (l.canonical_name () == "git:/#master");
}
{
repository_location l (loc ("/home/user/repo", repository_type::dir));
- assert (l.string () == "/home/user/repo");
+ assert (l.string () == "dir+file:///home/user/repo");
assert (l.canonical_name () == "dir:/home/user/repo");
}
#else
@@ -389,30 +419,30 @@ namespace bpkg
{
repository_location l (loc ("file:/c:/git/repo#branch",
repository_type::git));
- assert (l.string () == "file:/c:/git/repo#branch");
+ assert (l.string () == "git+file:/c:/git/repo#branch");
assert (l.canonical_name () == "git:c:\\git\\repo#branch");
}
{
repository_location l (loc ("c:\\git\\repo#branch",
repository_type::git));
- assert (l.string () == "file:/c:/git/repo#branch");
+ assert (l.string () == "git+file:/c:/git/repo#branch");
assert (l.canonical_name () == "git:c:\\git\\repo#branch");
}
{
repository_location l (loc ("file://localhost/c:/",
repository_type::git));
- assert (l.string () == "c:");
+ assert (l.string () == "git+file:///c:");
assert (l.canonical_name () == "git:c:");
}
{
repository_location l (loc ("file://localhost/c:/#master",
repository_type::git));
- assert (l.string () == "file:/c:#master");
+ assert (l.string () == "git+file:/c:#master");
assert (l.canonical_name () == "git:c:#master");
}
{
repository_location l (loc ("c:\\user\\repo", repository_type::dir));
- assert (l.string () == "c:\\user\\repo");
+ assert (l.string () == "dir+file:///c:/user/repo");
assert (l.canonical_name () == "dir:c:\\user\\repo");
}
#endif
@@ -506,7 +536,7 @@ namespace bpkg
{
repository_location l (loc ("http://git.example.com#master",
repository_type::git));
- assert (l.string () == "http://git.example.com/#master");
+ assert (l.string () == "git+http://git.example.com/#master");
assert (l.canonical_name () == "git:example.com#master");
}
{
@@ -514,7 +544,7 @@ namespace bpkg
*u.path /= path ("..");
repository_location l (u, repository_type::git);
- assert (l.string () == "http://git.example.com/#master");
+ assert (l.string () == "git+http://git.example.com/#master");
assert (l.canonical_name () == "git:example.com#master");
}
{
@@ -585,6 +615,14 @@ namespace bpkg
assert (l.canonical_name () == "pkg:stable.cppget.org");
}
{
+ repository_location l (typed_loc ("git+http://example.com/repo"));
+ assert (l.string () == "git+http://example.com/repo");
+ }
+ {
+ repository_location l (typed_loc ("http://example.com/repo.git"));
+ assert (l.string () == "http://example.com/repo.git");
+ }
+ {
repository_location l1 (loc ("http://stable.cppget.org/1/misc"));
repository_location l2 (loc ("../../1/math", l1));
assert (l2.string () == "http://stable.cppget.org/1/math");