From f2c64828c57e2993a7dd6f9f877069aa2e4667d4 Mon Sep 17 00:00:00 2001 From: "Ariel Shaqed (Scolnicov)" Date: Fri, 10 Jan 2025 10:03:48 +0200 Subject: [PATCH] Add a test for ListBranches "prefix" branch (#8481) Issue #8479 _asks_ for this arg, but it already exists. It exists and is in use, but obviously we can do better at promoting it. --- pkg/catalog/catalog_test.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pkg/catalog/catalog_test.go b/pkg/catalog/catalog_test.go index 11877a52556..bd9d2215988 100644 --- a/pkg/catalog/catalog_test.go +++ b/pkg/catalog/catalog_test.go @@ -316,6 +316,7 @@ func TestCatalog_ListBranches(t *testing.T) { {BranchID: "branch1", Branch: &graveler.Branch{CommitID: "commit1"}}, {BranchID: "branch2", Branch: &graveler.Branch{CommitID: "commit2"}}, {BranchID: "branch3", Branch: &graveler.Branch{CommitID: "commit3"}}, + {BranchID: "that_branch", Branch: &graveler.Branch{CommitID: "commit4"}}, } type args struct { prefix string @@ -336,17 +337,19 @@ func TestCatalog_ListBranches(t *testing.T) { {Name: "branch1", Reference: "commit1"}, {Name: "branch2", Reference: "commit2"}, {Name: "branch3", Reference: "commit3"}, + {Name: "that_branch", Reference: "commit4"}, }, wantHasMore: false, wantErr: false, }, { name: "exact", - args: args{limit: 3}, + args: args{limit: 4}, want: []*catalog.Branch{ {Name: "branch1", Reference: "commit1"}, {Name: "branch2", Reference: "commit2"}, {Name: "branch3", Reference: "commit3"}, + {Name: "that_branch", Reference: "commit4"}, }, wantHasMore: false, wantErr: false, @@ -370,11 +373,23 @@ func TestCatalog_ListBranches(t *testing.T) { wantErr: false, }, { - name: "last2", + name: "tail", args: args{limit: 10, after: "branch1"}, want: []*catalog.Branch{ {Name: "branch2", Reference: "commit2"}, {Name: "branch3", Reference: "commit3"}, + {Name: "that_branch", Reference: "commit4"}, + }, + wantHasMore: false, + wantErr: false, + }, + { + name: "prefix", + args: args{limit: -1, prefix: "branch"}, + want: []*catalog.Branch{ + {Name: "branch1", Reference: "commit1"}, + {Name: "branch2", Reference: "commit2"}, + {Name: "branch3", Reference: "commit3"}, }, wantHasMore: false, wantErr: false,