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:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-08 17:02:18 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-13 09:47:19 +0300
commitdac1c323929b21e9ab0fc98af3e79dec3495b2a0 (patch)
tree7d7c1d41a2c03b5c411174aa9cda8bec0041e348 /internal/gitaly/service/operations
parent5a38b03f6bce4c3cd329c835e8c2fbbeb6b65608 (diff)
tests: Convert to use `transaction.TrackingManager`
Convert tests to use the new `transaction.TrackingManager`, which simply records all votes which have been cast.
Diffstat (limited to 'internal/gitaly/service/operations')
-rw-r--r--internal/gitaly/service/operations/apply_patch_test.go16
-rw-r--r--internal/gitaly/service/operations/rebase_test.go14
2 files changed, 5 insertions, 25 deletions
diff --git a/internal/gitaly/service/operations/apply_patch_test.go b/internal/gitaly/service/operations/apply_patch_test.go
index 89b50f4f0..b0676804d 100644
--- a/internal/gitaly/service/operations/apply_patch_test.go
+++ b/internal/gitaly/service/operations/apply_patch_test.go
@@ -1,12 +1,10 @@
package operations
import (
- "context"
"fmt"
"io"
"os"
"strings"
- "sync/atomic"
"testing"
"testing/iotest"
"time"
@@ -26,7 +24,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
"gitlab.com/gitlab-org/gitaly/v14/internal/transaction/txinfo"
- "gitlab.com/gitlab-org/gitaly/v14/internal/transaction/voting"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/v14/streamio"
"google.golang.org/grpc/codes"
@@ -621,16 +618,7 @@ func TestUserApplyPatchTransactional(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- var votes int32
- txManager := &transaction.MockManager{
- VoteFn: func(context.Context, txinfo.Transaction, voting.Vote) error {
- // We can see a race here between adding the worktree and changing its
- // config and updating refs via the reference-transaction hook. Given that
- // both come in via different threads, Go perceives it as a potential race.
- atomic.AddInt32(&votes, 1)
- return nil
- },
- }
+ txManager := transaction.NewTrackingManager()
ctx, cfg, repoProto, repoPath, client := setupOperationsService(t, ctx, testserver.WithTransactionManager(txManager))
@@ -665,7 +653,7 @@ func TestUserApplyPatchTransactional(t *testing.T) {
require.True(t, response.BranchUpdate.BranchCreated)
- require.Equal(t, int32(14), votes)
+ require.Equal(t, 14, len(txManager.Votes()))
splitIndex := gittest.Exec(t, cfg, "-C", repoPath, "config", "core.splitIndex")
require.Equal(t, "false", text.ChompBytes(splitIndex))
diff --git a/internal/gitaly/service/operations/rebase_test.go b/internal/gitaly/service/operations/rebase_test.go
index 555c7048c..5c05880b3 100644
--- a/internal/gitaly/service/operations/rebase_test.go
+++ b/internal/gitaly/service/operations/rebase_test.go
@@ -1,7 +1,6 @@
package operations
import (
- "context"
"fmt"
"io"
"strings"
@@ -18,7 +17,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
"gitlab.com/gitlab-org/gitaly/v14/internal/transaction/txinfo"
- "gitlab.com/gitlab-org/gitaly/v14/internal/transaction/voting"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"google.golang.org/grpc/codes"
"google.golang.org/protobuf/proto"
@@ -93,13 +91,7 @@ func TestUserRebaseConfirmableTransaction(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- var voteCount int
- txManager := &transaction.MockManager{
- VoteFn: func(context.Context, txinfo.Transaction, voting.Vote) error {
- voteCount++
- return nil
- },
- }
+ txManager := transaction.NewTrackingManager()
ctx, cfg, repoProto, repoPath, client := setupOperationsService(
t, ctx,
@@ -141,7 +133,7 @@ func TestUserRebaseConfirmableTransaction(t *testing.T) {
t.Run(tc.desc, func(t *testing.T) {
preReceiveHookOutputPath := gittest.WriteEnvToCustomHook(t, repoPath, "pre-receive")
- voteCount = 0
+ txManager.Reset()
ctx := ctx
if tc.withTransaction {
@@ -173,7 +165,7 @@ func TestUserRebaseConfirmableTransaction(t *testing.T) {
require.Nil(t, response)
require.Equal(t, io.EOF, err)
- require.Equal(t, tc.expectedVotes, voteCount)
+ require.Equal(t, tc.expectedVotes, len(txManager.Votes()))
if tc.expectPreReceiveHook {
require.FileExists(t, preReceiveHookOutputPath)
} else {