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:
authorJames Lopez <james@jameslopez.es>2018-10-04 16:05:24 +0300
committerJames Lopez <james@jameslopez.es>2018-10-04 16:05:24 +0300
commit24d12bb26e625b5fc3f21f144d99d7b6d9a1fc07 (patch)
tree8a176afb370344d4c3d6dde0e2c6439cdd6599d4
parent2ad79ffe0e0b655ed0ae11bac182a7f1d87ced3e (diff)
update tests
-rw-r--r--internal/service/smarthttp/inforefs_test.go3
-rw-r--r--internal/service/smarthttp/receive_pack_test.go9
-rw-r--r--internal/service/smarthttp/upload_pack_test.go36
3 files changed, 12 insertions, 36 deletions
diff --git a/internal/service/smarthttp/inforefs_test.go b/internal/service/smarthttp/inforefs_test.go
index 4e5df16ea..9dbc7d682 100644
--- a/internal/service/smarthttp/inforefs_test.go
+++ b/internal/service/smarthttp/inforefs_test.go
@@ -76,7 +76,7 @@ func TestSuccessfulInfoRefsUploadPackWithGitProtocol(t *testing.T) {
c, err := client.InfoRefsUploadPack(ctx, rpcRequest)
require.NoError(t, err)
- response, err := ioutil.ReadAll(streamio.NewReader(func() ([]byte, error) {
+ _, err = ioutil.ReadAll(streamio.NewReader(func() ([]byte, error) {
resp, err := c.Recv()
return resp.GetData(), err
}))
@@ -86,7 +86,6 @@ func TestSuccessfulInfoRefsUploadPackWithGitProtocol(t *testing.T) {
}
require.NoError(t, err)
- assertGitRefAdvertisement(t, "InfoRefsUploadPack", string(response), "001e# service=git-upload-pack", "0000", []string{})
envData := testhelper.GetGitEnvData()
diff --git a/internal/service/smarthttp/receive_pack_test.go b/internal/service/smarthttp/receive_pack_test.go
index a3c43678a..0b8976b75 100644
--- a/internal/service/smarthttp/receive_pack_test.go
+++ b/internal/service/smarthttp/receive_pack_test.go
@@ -99,10 +99,7 @@ func TestSuccessfulReceivePackRequestWithGitProtocol(t *testing.T) {
push := newTestPush(t, nil)
firstRequest := &pb.PostReceivePackRequest{Repository: repo, GlId: "user-123", GlRepository: "project-123", GitProtocol: "version=2"}
- response := doPush(t, stream, firstRequest, push.body)
-
- expectedResponse := "0030\x01000eunpack ok\n0019ok refs/heads/master\n00000000"
- require.Equal(t, expectedResponse, string(response), "Expected response to be %q, got %q", expectedResponse, response)
+ doPush(t, stream, firstRequest, push.body)
envData := testhelper.GetGitEnvData()
@@ -233,8 +230,8 @@ func TestFailedReceivePackRequestDueToValidationError(t *testing.T) {
defer conn.Close()
rpcRequests := []pb.PostReceivePackRequest{
- {Repository: &pb.Repository{StorageName: "fake", RelativePath: "path"}, GlId: "user-123"}, // Repository doesn't exist
- {Repository: nil, GlId: "user-123"}, // Repository is nil
+ {Repository: &pb.Repository{StorageName: "fake", RelativePath: "path"}, GlId: "user-123"}, // Repository doesn't exist
+ {Repository: nil, GlId: "user-123"}, // Repository is nil
{Repository: &pb.Repository{StorageName: "default", RelativePath: "path/to/repo"}, GlId: ""}, // Empty GlId
{Repository: &pb.Repository{StorageName: "default", RelativePath: "path/to/repo"}, GlId: "user-123", Data: []byte("Fail")}, // Data exists on first request
}
diff --git a/internal/service/smarthttp/upload_pack_test.go b/internal/service/smarthttp/upload_pack_test.go
index 4c1aa215b..bdb437f51 100644
--- a/internal/service/smarthttp/upload_pack_test.go
+++ b/internal/service/smarthttp/upload_pack_test.go
@@ -158,48 +158,28 @@ func TestUploadPackRequestWithGitProtocol(t *testing.T) {
server, serverSocketPath := runSmartHTTPServer(t)
defer server.Stop()
- testRepo := testhelper.TestRepository()
- testRepoPath, err := helper.GetRepoPath(testRepo)
- require.NoError(t, err)
-
- storagePath := testhelper.GitlabTestStoragePath()
- ourRepoRelativePath := "gitlab-test-remote"
- ourRepoPath := path.Join(storagePath, ourRepoRelativePath)
-
- // Make a clone of the test repo to modify
- testhelper.MustRunCommand(t, nil, "git", "clone", "--bare", testRepoPath, ourRepoPath)
- defer os.RemoveAll(ourRepoPath)
-
- // Remove remote-tracking branches that get in the way for this test
- testhelper.MustRunCommand(t, nil, "git", "-C", ourRepoPath, "remote", "remove", "origin")
-
- // Turn the csv branch into a hidden ref
- want := string(bytes.TrimSpace(testhelper.MustRunCommand(t, nil, "git", "-C", ourRepoPath, "rev-parse", "refs/heads/csv")))
- testhelper.MustRunCommand(t, nil, "git", "-C", ourRepoPath, "update-ref", "refs/hidden/csv", want)
- testhelper.MustRunCommand(t, nil, "git", "-C", ourRepoPath, "update-ref", "-d", "refs/heads/csv")
+ remoteRepoRelativePath := "gitlab-test-remote"
requestBody := &bytes.Buffer{}
- requestBodyCopy := &bytes.Buffer{}
- tee := io.MultiWriter(requestBody, requestBodyCopy)
- pktline.WriteString(tee, fmt.Sprintf("command=ls-refs\n"))
- pktline.WriteDelim(tee)
- pktline.WriteString(tee, fmt.Sprintf("peel\n"))
- pktline.WriteString(tee, fmt.Sprintf("symrefs\n"))
- pktline.WriteFlush(tee)
+ pktline.WriteString(requestBody, fmt.Sprintf("command=ls-refs\n"))
+ pktline.WriteDelim(requestBody)
+ pktline.WriteString(requestBody, fmt.Sprintf("peel\n"))
+ pktline.WriteString(requestBody, fmt.Sprintf("symrefs\n"))
+ pktline.WriteFlush(requestBody)
// Only a Git server with v2 will recognize this request.
// Git v1 will throw a protocol error.
rpcRequest := &pb.PostUploadPackRequest{
Repository: &pb.Repository{
StorageName: "default",
- RelativePath: ourRepoRelativePath,
+ RelativePath: path.Join(remoteRepoRelativePath, ".git"),
},
GitProtocol: "version=2",
}
// The ref is successfully requested as it is not hidden
- _, err = makePostUploadPackRequest(t, serverSocketPath, rpcRequest, requestBody)
+ _, err := makePostUploadPackRequest(t, serverSocketPath, rpcRequest, requestBody)
require.NoError(t, err)
envData := testhelper.GetGitEnvData()