Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarthik Nayak <knayak@gitlab.com>2022-08-26 11:20:14 +0300
committerKarthik Nayak <knayak@gitlab.com>2022-08-26 12:39:09 +0300
commit8c281676b3bfbba15c0eda70237631cf84e0f84d (patch)
tree65946f36bd6ad7489e294646ab16694c1d42255b
parentfcf5889846c2260697e5507df8428fbbf4d4ebd8 (diff)
testhelper: Introduce a new 'assertContainsBranch'
In the previous commit (cd071fd027d4dddecf69db4477e2becb25becf59) we renamed 'assertContainsBranch' to 'assertContainsAllBranchesResponseBranch'. In this commit, let's introduce a new 'assertContainsBranch' function which checks if a 'gitalypb.Branch' is present in a list of the same type.
-rw-r--r--internal/gitaly/service/ref/testhelper_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/gitaly/service/ref/testhelper_test.go b/internal/gitaly/service/ref/testhelper_test.go
index 803ab1263..cd5e4ee1c 100644
--- a/internal/gitaly/service/ref/testhelper_test.go
+++ b/internal/gitaly/service/ref/testhelper_test.go
@@ -137,6 +137,22 @@ func assertContainsAllBranchesResponseBranch(t *testing.T, branches []*gitalypb.
t.Errorf("Expected to find branch %q in branches %s", branch.Name, branchNames)
}
+func assertContainsBranch(t *testing.T, branches []*gitalypb.Branch, branch *gitalypb.Branch) {
+ t.Helper()
+
+ var branchNames [][]byte
+
+ for _, b := range branches {
+ if bytes.Equal(branch.Name, b.Name) {
+ testhelper.ProtoEqual(t, b.TargetCommit, branch.TargetCommit)
+ return // Found the branch and it matches. Success!
+ }
+ branchNames = append(branchNames, b.Name)
+ }
+
+ t.Errorf("Expected to find branch %q in branches %s", branch.Name, branchNames)
+}
+
func gitalyOrPraefect(gitalyMsg, praefectMsg string) string {
if testhelper.IsPraefectEnabled() {
return praefectMsg