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:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2020-12-04 04:20:23 +0300
committerÆvar Arnfjörð Bjarmason <avarab@gmail.com>2020-12-08 12:05:04 +0300
commitac1e929abfa1b7e81b6221d0e63ee0f488ad999b (patch)
treeb1f22e95cb2c6d3219a8d3c188b92df7d0a435b9
parentb6987c25a754802312fa05fecc4017bb1d1ff8b7 (diff)
UserCreateTag tests: test creation of "refs/tags/NAME" tags
Copy over a test I added in 8b0a877a8 (Port UserDeleteTag to Go, 2020-11-16) for tag deletion to test the same condition for tag creation.
-rw-r--r--internal/gitaly/service/operations/tags_test.go63
1 files changed, 62 insertions, 1 deletions
diff --git a/internal/gitaly/service/operations/tags_test.go b/internal/gitaly/service/operations/tags_test.go
index 0cb0a5ed4..a83a98af5 100644
--- a/internal/gitaly/service/operations/tags_test.go
+++ b/internal/gitaly/service/operations/tags_test.go
@@ -298,7 +298,7 @@ func testUserDeleteTagsuccessfulDeletionOfPrefixedTag(t *testing.T, ctx context.
response, err := client.UserDeleteTag(ctx, request)
require.Equal(t, testCase.err, err)
- testhelper.ProtoEqual(t, testCase.response, response)
+ require.Equal(t, testCase.response, response)
refs := testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "for-each-ref", "--", "refs/tags/"+testCase.tagNameInput)
require.NotContains(t, string(refs), testCase.tagCommit, "tag kept because we stripped off refs/tags/*")
@@ -306,6 +306,67 @@ func testUserDeleteTagsuccessfulDeletionOfPrefixedTag(t *testing.T, ctx context.
}
}
+func TestUserCreateTagsuccessfulCreationOfPrefixedTag(t *testing.T) {
+ testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
+ defer cleanupFn()
+
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
+
+ client, conn := newOperationClient(t, serverSocketPath)
+ defer conn.Close()
+
+ testCases := []struct {
+ desc string
+ tagNameInput string
+ tagTargetRevisionInput string
+ user *gitalypb.User
+ err error
+ }{
+ {
+ desc: "possible to create a tag called refs/tags/something",
+ tagNameInput: "refs/tags/can-create-this",
+ tagTargetRevisionInput: "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863",
+ user: testhelper.TestUser,
+ err: nil,
+ },
+ }
+
+ for _, testCase := range testCases {
+ t.Run(testCase.desc, func(t *testing.T) {
+ defer exec.Command(config.Config.Git.BinPath, "-C", testRepoPath, "tag", "-d", testCase.tagNameInput).Run()
+
+ request := &gitalypb.UserCreateTagRequest{
+ Repository: testRepo,
+ TagName: []byte(testCase.tagNameInput),
+ TargetRevision: []byte(testCase.tagTargetRevisionInput),
+ User: testCase.user,
+ }
+
+ ctx, cancel := testhelper.Context()
+ defer cancel()
+
+ response, err := client.UserCreateTag(ctx, request)
+ require.Equal(t, testCase.err, err)
+ commitOk, err := log.GetCommit(ctx, testRepo, testCase.tagTargetRevisionInput)
+ require.NoError(t, err)
+
+ responseOk := &gitalypb.UserCreateTagResponse{
+ Tag: &gitalypb.Tag{
+ Name: []byte(testCase.tagNameInput),
+ Id: testCase.tagTargetRevisionInput,
+ TargetCommit: commitOk,
+ },
+ }
+
+ require.Equal(t, responseOk, response)
+
+ refs := testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "for-each-ref", "--", "refs/tags/"+testCase.tagNameInput)
+ require.Contains(t, string(refs), testCase.tagTargetRevisionInput, "tag created, we did not strip off refs/tags/*")
+ })
+ }
+}
+
func TestSuccessfulGitHooksForUserCreateTagRequest(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()