1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
package rubyserver
import (
"testing"
"github.com/stretchr/testify/assert"
pb "gitlab.com/gitlab-org/gitaly-proto/go"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"google.golang.org/grpc/codes"
)
func TestStopSafe(t *testing.T) {
badServers := []*Server{
nil,
&Server{},
}
for _, bs := range badServers {
bs.Stop()
}
}
func TestSetHeaders(t *testing.T) {
testRepo := testhelper.TestRepository()
testCases := []struct {
repo *pb.Repository
errType codes.Code
}{
{
repo: &pb.Repository{StorageName: "foo", RelativePath: "bar.git"},
errType: codes.InvalidArgument,
},
{
repo: testRepo,
errType: codes.OK,
},
}
for _, tc := range testCases {
ctx, cancel := testhelper.Context()
defer cancel()
clientCtx, err := SetHeaders(ctx, tc.repo)
if tc.errType != codes.OK {
testhelper.AssertGrpcError(t, err, tc.errType, "")
assert.Nil(t, clientCtx)
} else {
assert.NoError(t, err)
assert.NotNil(t, clientCtx)
}
}
}
|