From 2c2551685ff85c024ccd2c8d7f9db8ab9dc52481 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 11 Jan 2022 15:27:24 +0100 Subject: gittest: Provide helper function to create command factories We're about to change the ExecCommandFactory to carry state soonish, which both requires us to return an error code and a cleanup function. This is going to become tedious to manage in our tests given that there's many locations where we construct the factory. Introduce a new function `gittest.NewCommandFactory()` to be used in tests, such that callsites don't have to handle all of this. --- cmd/gitaly-ssh/auth_test.go | 3 +-- cmd/gitaly-ssh/upload_pack_test.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'cmd/gitaly-ssh') diff --git a/cmd/gitaly-ssh/auth_test.go b/cmd/gitaly-ssh/auth_test.go index 8a17d7130..b0e84456a 100644 --- a/cmd/gitaly-ssh/auth_test.go +++ b/cmd/gitaly-ssh/auth_test.go @@ -13,7 +13,6 @@ import ( "gitlab.com/gitlab-org/gitaly/v14/client" "gitlab.com/gitlab-org/gitaly/v14/internal/backchannel" "gitlab.com/gitlab-org/gitaly/v14/internal/cache" - "gitlab.com/gitlab-org/gitaly/v14/internal/git" "gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/hook" @@ -148,7 +147,7 @@ func runServer(t *testing.T, secure bool, cfg config.Cfg, connectionType string, locator := config.NewLocator(cfg) registry := backchannel.NewRegistry() txManager := transaction.NewManager(cfg, registry) - gitCmdFactory := git.NewExecCommandFactory(cfg) + gitCmdFactory := gittest.NewCommandFactory(t, cfg) hookManager := hook.NewManager(cfg, locator, gitCmdFactory, txManager, gitlab.NewMockClient( t, gitlab.MockAllowed, gitlab.MockPreReceive, gitlab.MockPostReceive, )) diff --git a/cmd/gitaly-ssh/upload_pack_test.go b/cmd/gitaly-ssh/upload_pack_test.go index 504f5c2e9..9d2ae412e 100644 --- a/cmd/gitaly-ssh/upload_pack_test.go +++ b/cmd/gitaly-ssh/upload_pack_test.go @@ -40,7 +40,7 @@ func TestVisibilityOfHiddenRefs(t *testing.T) { existingSha := "1e292f8fedd741b75372e19097c76d327140c312" keepAroundRef := fmt.Sprintf("%s/%s", keepAroundNamespace, existingSha) - gitCmdFactory := git.NewExecCommandFactory(cfg) + gitCmdFactory := gittest.NewCommandFactory(t, cfg) localRepo := localrepo.NewTestRepo(t, cfg, repo) updater, err := updateref.New(ctx, cfg, localRepo) -- cgit v1.2.3