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

protocol_test.go « git « internal - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1c87e9157f8aad358952c27284fac2d5e77e37c6 (plain)
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
package git

import (
	"testing"

	"github.com/stretchr/testify/require"
	"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
)

type fakeProtocolMessage struct {
	protocol string
}

func (f fakeProtocolMessage) GetGitProtocol() string {
	return f.protocol
}

func TestGitProtocolEnv(t *testing.T) {
	for _, tt := range []struct {
		desc string
		msg  fakeProtocolMessage
		env  []string
	}{
		{
			desc: "no V2 request",
			env:  nil,
		},
		{
			desc: "V2 request",
			msg:  fakeProtocolMessage{protocol: "version=2"},
			env:  []string{"GIT_PROTOCOL=version=2"},
		},
	} {
		t.Run(tt.desc, func(t *testing.T) {
			ctx, cancel := testhelper.Context()
			defer cancel()

			actual := gitProtocolEnv(ctx, tt.msg)
			require.Equal(t, tt.env, actual)
		})
	}
}