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:
Diffstat (limited to 'internal')
-rw-r--r--internal/gitaly/service/hook/pack_objects_test.go20
-rw-r--r--internal/testhelper/grpc.go11
2 files changed, 27 insertions, 4 deletions
diff --git a/internal/gitaly/service/hook/pack_objects_test.go b/internal/gitaly/service/hook/pack_objects_test.go
index a4b562240..8d1344983 100644
--- a/internal/gitaly/service/hook/pack_objects_test.go
+++ b/internal/gitaly/service/hook/pack_objects_test.go
@@ -8,6 +8,7 @@ import (
"fmt"
"io"
"net"
+ "runtime"
"strings"
"sync"
"testing"
@@ -16,6 +17,7 @@ import (
"github.com/prometheus/client_golang/prometheus/testutil"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
+ "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/gittest"
@@ -149,8 +151,18 @@ func testServerPackObjectsHookSeparateContextWithRuntimeDir(t *testing.T, ctx co
go func() {
defer wg.Done()
_, err := client1.PackObjectsHookWithSidechannel(ctx1, req)
- testhelper.RequireGrpcCode(t, err, codes.Canceled)
- require.NoError(t, wt1.Wait())
+
+ if runtime.GOOS == "darwin" {
+ assert.Contains(t, []codes.Code{codes.Canceled, codes.Internal}, status.Code(err))
+
+ if status.Code(err) == codes.Internal {
+ assert.Contains(t, err.Error(), "write: socket is not connected")
+ }
+ } else {
+ testhelper.AssertGrpcCode(t, err, codes.Canceled)
+ }
+
+ assert.NoError(t, wt1.Wait())
}()
// Call 2: this is a normal call with the same request as call 1
@@ -189,8 +201,8 @@ func testServerPackObjectsHookSeparateContextWithRuntimeDir(t *testing.T, ctx co
go func() {
defer wg.Done()
_, err := client2.PackObjectsHookWithSidechannel(ctx2, req)
- require.NoError(t, err)
- require.NoError(t, wt2.Wait())
+ assert.NoError(t, err)
+ assert.NoError(t, wt2.Wait())
}()
close(start1)
diff --git a/internal/testhelper/grpc.go b/internal/testhelper/grpc.go
index 8cf96b326..3815bc6e3 100644
--- a/internal/testhelper/grpc.go
+++ b/internal/testhelper/grpc.go
@@ -6,6 +6,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
+ "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
@@ -50,6 +51,16 @@ func RequireGrpcCode(tb testing.TB, err error, expectedCode codes.Code) {
require.Equal(tb, expectedCode, status.Code())
}
+// AssertGrpcCode asserts that the error has the expected gRPC status code.
+func AssertGrpcCode(tb testing.TB, err error, expectedCode codes.Code) {
+ tb.Helper()
+
+ assert.Error(tb, err)
+ status, ok := status.FromError(err)
+ assert.True(tb, ok)
+ assert.Equal(tb, expectedCode, status.Code())
+}
+
// RequireGrpcError asserts that expected and actual gRPC errors are equal. Comparing gRPC errors
// directly with `require.Equal()` will not typically work correct.
func RequireGrpcError(tb testing.TB, expected, actual error) {