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
|
package git
import (
"testing"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v16/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 := testhelper.Context(t)
actual := gitProtocolEnv(ctx, tt.msg)
require.Equal(t, tt.env, actual)
})
}
}
|