From 18e40e91c99088ef5fb9458ec4c1ec21ddcc51e6 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 14 Feb 2018 19:27:47 +0300 Subject: Add support for git manifests --- tests/repository-location/driver.cxx | 44 ++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'tests/repository-location/driver.cxx') diff --git a/tests/repository-location/driver.cxx b/tests/repository-location/driver.cxx index ad3b0dd..e4282fe 100644 --- a/tests/repository-location/driver.cxx +++ b/tests/repository-location/driver.cxx @@ -33,9 +33,11 @@ namespace bpkg } inline static repository_location - loc (const string& l, const repository_location& b) + loc (const string& l, + const repository_location& b, + repository_type t = repository_type::bpkg) { - return repository_location (repository_url (l), b); + return repository_location (repository_url (l), t, b); } inline static bool @@ -53,11 +55,13 @@ namespace bpkg } inline static bool - bad_loc (const string& l, const repository_location& b) + bad_loc (const string& l, + const repository_location& b, + repository_type t = repository_type::bpkg) { try { - repository_location bl (repository_url (l), b); + repository_location bl (repository_url (l), t, b); return false; } catch (const invalid_argument&) @@ -71,7 +75,7 @@ namespace bpkg { istringstream is (":1\nurl: " + l); manifest_parser mp (is, ""); - repository_manifest m (mp); + repository_manifest m (bpkg_repository_manifest (mp)); optional u (m.effective_url (r)); assert (u); @@ -307,6 +311,11 @@ namespace bpkg assert (l.canonical_name () == "git:/git/repo"); } { + repository_location l (loc ("/git/repo#branch", repository_type::git)); + assert (l.string () == "file:/git/repo#branch"); + assert (l.canonical_name () == "git:/git/repo"); + } + { repository_location l (loc ("file://localhost/#master", repository_type::git)); assert (l.string () == "file:/#master"); @@ -368,6 +377,12 @@ namespace bpkg assert (l.canonical_name () == "git:c:\\git\\repo"); } { + repository_location l (loc ("c:\\git\\repo#branch", + repository_type::git)); + assert (l.string () == "file:/c:/git/repo#branch"); + assert (l.canonical_name () == "git:c:\\git\\repo"); + } + { repository_location l (loc ("file://localhost/c:/#master", repository_type::git)); assert (l.string () == "file:/c:#master"); @@ -435,6 +450,7 @@ namespace bpkg assert (l.string () == "http://example.com/test.git#master"); assert (l.canonical_name () == "git:example.com/test"); assert (l.proto () == proto::http); + assert (l.type () == repository_type::git); } { repository_location l (loc ("https://example.com/test.git#master", @@ -576,6 +592,24 @@ namespace bpkg assert (l2.canonical_name () == "bpkg:stable.cppget.org:444/math"); assert (l2.proto () == proto::https); } + { + repository_location l (loc ("../test.git#master", + repository_location (), + repository_type::git)); + assert (l.string () == "../test.git#master"); + assert (l.canonical_name ().empty ()); + assert (l.proto () == proto::file); + } + { + repository_location l1 (loc ("https://example.com/stable.git#stable", + repository_type::git)); + repository_location l2 (loc ("../test.git#master", + l1, + repository_type::git)); + assert (l2.string () == "https://example.com/test.git#master"); + assert (l2.canonical_name () == "git:example.com/test"); + assert (l2.proto () == proto::https); + } #ifndef _WIN32 { repository_location l1 (loc ("/var/r1/1/misc")); -- cgit v1.1