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

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

import (
	"context"
	"io/ioutil"
	"net/http"
	"net/http/httptest"
	"os"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestGitCommandProxy(t *testing.T) {
	requestReceived := false

	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		requestReceived = true
	}))
	defer ts.Close()

	oldHTTPProxy := os.Getenv("http_proxy")
	defer os.Setenv("http_proxy", oldHTTPProxy)

	os.Setenv("http_proxy", ts.URL)

	ctx, _ := context.WithCancel(context.Background())

	dir, err := ioutil.TempDir("", "test-clone")
	require.NoError(t, err)
	defer os.RemoveAll(dir)

	cmd, err := unsafeCmdWithoutRepo(ctx, "clone", "http://gitlab.com/bogus-repo", dir)
	require.NoError(t, err)

	err = cmd.Wait()
	require.NoError(t, err)
	require.True(t, requestReceived)
}