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:
authorJames Fargher <jfargher@gitlab.com>2022-10-28 02:32:47 +0300
committerJames Fargher <jfargher@gitlab.com>2022-10-28 02:32:47 +0300
commit5a6b64b2638371534b3d4242062cd9dd8259a887 (patch)
tree328071e0fc2c244d4578c8529a94dec08efcceaa
parent78353a338640da2902ff9880fd8ee293e96200fe (diff)
operations: Improve UserCherryPick error handling tests
These tests were only checking the error code which can easily end up failing in unexpected ways. Instead here we start asserting the actual error messages to ensure they correlate with the test at hand.
-rw-r--r--internal/gitaly/service/operations/cherry_pick_test.go23
1 files changed, 15 insertions, 8 deletions
diff --git a/internal/gitaly/service/operations/cherry_pick_test.go b/internal/gitaly/service/operations/cherry_pick_test.go
index 075b095bb..4dd012388 100644
--- a/internal/gitaly/service/operations/cherry_pick_test.go
+++ b/internal/gitaly/service/operations/cherry_pick_test.go
@@ -290,9 +290,10 @@ func TestServer_UserCherryPick_failedValidations(t *testing.T) {
destinationBranch := "cherry-picking-dst"
testCases := []struct {
- desc string
- request *gitalypb.UserCherryPickRequest
- code codes.Code
+ desc string
+ request *gitalypb.UserCherryPickRequest
+ expectedErrCode codes.Code
+ expectedErrMsg string
}{
{
desc: "empty user",
@@ -303,7 +304,8 @@ func TestServer_UserCherryPick_failedValidations(t *testing.T) {
BranchName: []byte(destinationBranch),
Message: []byte("Cherry-picking " + cherryPickedCommit.Id),
},
- code: codes.InvalidArgument,
+ expectedErrCode: codes.InvalidArgument,
+ expectedErrMsg: "rpc error: code = InvalidArgument desc = UserCherryPick: empty User",
},
{
desc: "empty commit",
@@ -314,7 +316,8 @@ func TestServer_UserCherryPick_failedValidations(t *testing.T) {
BranchName: []byte(destinationBranch),
Message: []byte("Cherry-picking " + cherryPickedCommit.Id),
},
- code: codes.InvalidArgument,
+ expectedErrCode: codes.InvalidArgument,
+ expectedErrMsg: "rpc error: code = InvalidArgument desc = UserCherryPick: empty Commit",
},
{
desc: "empty branch name",
@@ -325,7 +328,8 @@ func TestServer_UserCherryPick_failedValidations(t *testing.T) {
BranchName: nil,
Message: []byte("Cherry-picking " + cherryPickedCommit.Id),
},
- code: codes.InvalidArgument,
+ expectedErrCode: codes.InvalidArgument,
+ expectedErrMsg: "rpc error: code = InvalidArgument desc = UserCherryPick: empty BranchName",
},
{
desc: "empty message",
@@ -336,14 +340,17 @@ func TestServer_UserCherryPick_failedValidations(t *testing.T) {
BranchName: []byte(destinationBranch),
Message: nil,
},
- code: codes.InvalidArgument,
+ expectedErrCode: codes.InvalidArgument,
+ expectedErrMsg: "rpc error: code = InvalidArgument desc = UserCherryPick: empty Message",
},
}
for _, testCase := range testCases {
t.Run(testCase.desc, func(t *testing.T) {
_, err := client.UserCherryPick(ctx, testCase.request)
- testhelper.RequireGrpcCode(t, err, testCase.code)
+
+ testhelper.RequireGrpcCode(t, err, testCase.expectedErrCode)
+ require.EqualError(t, err, testCase.expectedErrMsg)
})
}
}