diff options
author | Patrick Bajao <ebajao@gitlab.com> | 2019-02-28 15:21:20 +0300 |
---|---|---|
committer | Patrick Bajao <ebajao@gitlab.com> | 2019-03-01 03:46:50 +0300 |
commit | 00d8f64de6921202c2e61c60b50db78f5d59ec49 (patch) | |
tree | 2228b4bf3fffeec547dc9f5ef5d84e21f1beb55f | |
parent | 2d18b28e864391d453fdf8694ba1640fcdadc9bc (diff) |
Update test to cover more cases
-rw-r--r-- | internal/service/operations/commit_files_test.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/internal/service/operations/commit_files_test.go b/internal/service/operations/commit_files_test.go index 402cef513..6c58e0b5e 100644 --- a/internal/service/operations/commit_files_test.go +++ b/internal/service/operations/commit_files_test.go @@ -3,6 +3,7 @@ package operations_test import ( "fmt" "strconv" + "strings" "testing" "github.com/stretchr/testify/require" @@ -208,7 +209,7 @@ func TestSuccessfulUserCommitFilesRequestForceCommit(t *testing.T) { client, conn := operations.NewOperationClient(t, serverSocketPath) defer conn.Close() - testRepo, _, cleanupFn := testhelper.NewTestRepo(t) + testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() ctxOuter, cancel := testhelper.Context() @@ -226,12 +227,16 @@ func TestSuccessfulUserCommitFilesRequestForceCommit(t *testing.T) { targetBranchCommit, err := log.GetCommit(ctxOuter, testRepo, targetBranchName) require.NoError(t, err) - require.NotContains(t, targetBranchCommit.ParentIds, startBranchCommit.Id) + + mergeBaseOut := testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "merge-base", targetBranchCommit.Id, startBranchCommit.Id) + mergeBaseID := strings.TrimSuffix(string(mergeBaseOut), "\n") + require.NotEqual(t, mergeBaseID, targetBranchCommit.Id, "expected %s not to be an ancestor of %s", targetBranchCommit.Id, startBranchCommit.Id) headerRequest := headerRequest(testRepo, user, targetBranchName, commitFilesMessage, authorName, authorEmail) header := headerRequest.UserCommitFilesRequestPayload.(*gitalypb.UserCommitFilesRequest_Header).Header header.StartBranchName = startBranchName header.Force = true + stream, err := client.UserCommitFiles(ctx) require.NoError(t, err) require.NoError(t, stream.Send(headerRequest)) @@ -242,10 +247,11 @@ func TestSuccessfulUserCommitFilesRequestForceCommit(t *testing.T) { require.NoError(t, err) update := r.GetBranchUpdate() - targetBranchCommit, err = log.GetCommit(ctxOuter, testRepo, targetBranchName) + newTargetBranchCommit, err := log.GetCommit(ctxOuter, testRepo, targetBranchName) require.NoError(t, err) - require.Equal(t, targetBranchCommit.Id, update.CommitId) - require.Equal(t, targetBranchCommit.ParentIds, []string{startBranchCommit.Id}) + + require.Equal(t, newTargetBranchCommit.Id, update.CommitId) + require.Equal(t, newTargetBranchCommit.ParentIds, []string{startBranchCommit.Id}) } func TestFailedUserCommitFilesRequestDueToHooks(t *testing.T) { |