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
path: root/cmd
diff options
context:
space:
mode:
authorKarthik Nayak <knayak@gitlab.com>2023-11-29 20:03:28 +0300
committerKarthik Nayak <knayak@gitlab.com>2023-11-30 18:15:59 +0300
commit96c37cba249a36d5979d78ff6d2e686fb1a0328b (patch)
treeab7d8c7e554ecc95f899d72da229e0ed09f24d7b /cmd
parent232812c92f18f03372f73284c079d90e3c532923 (diff)
errors: Use `errors.As()` for type assertion
Currently for type assertion of errors, we use the `err.(<Interface>)` form. This works, but is not compatible with wrapped errors. So let's use `errors.As()` instead.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gitaly/main_test.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/cmd/gitaly/main_test.go b/cmd/gitaly/main_test.go
index b649c10aa..339d7cbd6 100644
--- a/cmd/gitaly/main_test.go
+++ b/cmd/gitaly/main_test.go
@@ -2,6 +2,7 @@ package main
import (
"bytes"
+ "errors"
"os/exec"
"testing"
@@ -63,8 +64,9 @@ func TestGitalyCLI(t *testing.T) {
err := cmd.Run()
exitCode := 0
- if err != nil {
- exitCode = err.(*exec.ExitError).ExitCode()
+ var exitErr *exec.ExitError
+ if errors.As(err, &exitErr) {
+ exitCode = exitErr.ExitCode()
}
assert.Equal(t, tc.exitCode, exitCode)