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-04-15 11:49:43 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-04-19 10:23:54 +0300
commitceba1579a711103c56c30e510a07d61444191717 (patch)
tree56c29af97229b70427da1bf4bc80652c2f3e3f96 /cmd/gitaly-hooks
parentf5c607b1ea9a59c35ae47b6b03bdf98ea183a379 (diff)
testhelper: Convert `WriteExecutable()` to use `t.Cleanup()`
Now that the minimum required Go version is 1.14, we have started to make use of `t.Cleanup()` to clean up temporary test state. Convert `WriteExecutable()` and some of its user to use it, too, instead of returning cleanup functions.
Diffstat (limited to 'cmd/gitaly-hooks')
-rw-r--r--cmd/gitaly-hooks/hooks_test.go15
1 files changed, 5 insertions, 10 deletions
diff --git a/cmd/gitaly-hooks/hooks_test.go b/cmd/gitaly-hooks/hooks_test.go
index dfad57eea..f0fd73693 100644
--- a/cmd/gitaly-hooks/hooks_test.go
+++ b/cmd/gitaly-hooks/hooks_test.go
@@ -158,8 +158,7 @@ func testHooksPrePostReceive(t *testing.T, cfg config.Cfg, repo *gitalypb.Reposi
for _, hookName := range hookNames {
t.Run(fmt.Sprintf("hookName: %s", hookName), func(t *testing.T) {
- customHookOutputPath, cleanup := gittest.WriteEnvToCustomHook(t, repoPath, hookName)
- defer cleanup()
+ customHookOutputPath := gittest.WriteEnvToCustomHook(t, repoPath, hookName)
gitlabAPI, err := gitalyhook.NewGitlabAPI(cfg.Gitlab, cfg.TLS)
require.NoError(t, err)
@@ -281,12 +280,10 @@ require 'json'
open('%s', 'w') { |f| f.puts(JSON.dump(ARGV)) }
`, customHookArgsPath)
// write a custom hook to path/to/repo.git/custom_hooks/update.d/dumpargsscript which dumps the args into a tempfile
- cleanup = testhelper.WriteExecutable(t, filepath.Join(repoPath, "custom_hooks", "update.d", "dumpargsscript"), []byte(dumpArgsToTempfileScript))
- defer cleanup()
+ testhelper.WriteExecutable(t, filepath.Join(repoPath, "custom_hooks", "update.d", "dumpargsscript"), []byte(dumpArgsToTempfileScript))
// write a custom hook to path/to/repo.git/custom_hooks/update which dumps the env into a tempfile
- customHookOutputPath, cleanup := gittest.WriteEnvToCustomHook(t, repoPath, "update")
- defer cleanup()
+ customHookOutputPath := gittest.WriteEnvToCustomHook(t, repoPath, "update")
var stdout, stderr bytes.Buffer
@@ -350,8 +347,7 @@ func TestHooksPostReceiveFailed(t *testing.T) {
stop := runHookServiceServerWithAPI(t, cfg, gitlabAPI)
defer stop()
- customHookOutputPath, cleanup := gittest.WriteEnvToCustomHook(t, repoPath, "post-receive")
- defer cleanup()
+ customHookOutputPath := gittest.WriteEnvToCustomHook(t, repoPath, "post-receive")
var stdout, stderr bytes.Buffer
@@ -460,8 +456,7 @@ func TestHooksNotAllowed(t *testing.T) {
cfg.Gitlab.URL = serverURL
cfg.Gitlab.SecretFile = testhelper.WriteShellSecretFile(t, cfg.GitlabShell.Dir, "the wrong token")
- customHookOutputPath, cleanup := gittest.WriteEnvToCustomHook(t, repoPath, "post-receive")
- defer cleanup()
+ customHookOutputPath := gittest.WriteEnvToCustomHook(t, repoPath, "post-receive")
gitlabAPI, err := gitalyhook.NewGitlabAPI(cfg.Gitlab, cfg.TLS)
require.NoError(t, err)