From bba520774fd6185f62a6bf52c61b98104a826f5f Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 19 Apr 2018 22:43:08 +0300 Subject: Add support for comma-separated list of git reference filter --- tests/repository-location/driver.cxx | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/repository-location/driver.cxx b/tests/repository-location/driver.cxx index 2e39c26..ee8fba1 100644 --- a/tests/repository-location/driver.cxx +++ b/tests/repository-location/driver.cxx @@ -19,6 +19,7 @@ using namespace butl; namespace bpkg { using butl::optional; + using butl::nullopt; inline static repository_location loc () @@ -99,6 +100,12 @@ namespace bpkg return true; } + inline static bool + operator== (const git_ref_filter& x, const git_ref_filter& y) + { + return x.commit == y.commit && x.name == y.name; + } + int main (int argc, char* argv[]) { @@ -159,6 +166,9 @@ namespace bpkg assert (bad_loc ("https://www.example.com/test.git#", repository_type::git)); + assert (bad_loc ("https://www.example.com/test.git#,", + repository_type::git)); + assert (bad_loc ("https://www.example.com/test.git#@", repository_type::git)); @@ -812,16 +822,20 @@ namespace bpkg // Repository URL fragments. // { - string branch ("master"); - string commit ("0a53e9ddeaddad63ad106860237bbf53411d11a7"); + string n ("master"); + string c ("0a53e9ddeaddad63ad106860237bbf53411d11a7"); + + assert (git_ref_filter (n) == git_ref_filter (n, nullopt)); + assert (git_ref_filter (c + "@") == git_ref_filter (c, nullopt)); + assert (git_ref_filter (c) == git_ref_filter (nullopt, c)); + assert (git_ref_filter ("@" + c) == git_ref_filter (nullopt, c)); + assert (git_ref_filter (n + "@" + c) == git_ref_filter (n, c)); - assert (*git_ref_filter (branch).name == branch); - assert (*git_ref_filter (commit + "@").name == commit); - assert (*git_ref_filter (commit).commit == commit); - assert (*git_ref_filter ("@" + commit).commit == commit); + assert (parse_git_ref_filters ("tag") == + git_ref_filters ({git_ref_filter ("tag")})); - git_ref_filter r (branch + "@" + commit); - assert (*r.name == branch && *r.commit == commit); + assert (parse_git_ref_filters ("a,b") == + git_ref_filters ({git_ref_filter ("a"), git_ref_filter ("b")})); } // repository_url -- cgit v1.1