summaryrefslogtreecommitdiff
path: root/internal/command/receivepack
diff options
context:
space:
mode:
authorIgor Drozdov <idrozdov@gitlab.com>2021-03-17 21:18:42 +0300
committerIgor Drozdov <idrozdov@gitlab.com>2021-03-17 21:23:07 +0300
commitee41d0dfb7b02a19f5926bfe24dbad1df417a29e (patch)
tree130f2777342645018f3f6b797ee0083d65910889 /internal/command/receivepack
parent4b40a2cb8c71a5b490cad4c8e1ad2dc0e9b39548 (diff)
downloadgitlab-shell-ee41d0dfb7b02a19f5926bfe24dbad1df417a29e.tar.gz
Replace cleanup functions with t.Cleanup
In this case we don't need to propagate cleanup function. It simplifies the code.
Diffstat (limited to 'internal/command/receivepack')
-rw-r--r--internal/command/receivepack/gitalycall_test.go6
-rw-r--r--internal/command/receivepack/receivepack_test.go12
2 files changed, 7 insertions, 11 deletions
diff --git a/internal/command/receivepack/gitalycall_test.go b/internal/command/receivepack/gitalycall_test.go
index d756248..9a1019d 100644
--- a/internal/command/receivepack/gitalycall_test.go
+++ b/internal/command/receivepack/gitalycall_test.go
@@ -19,12 +19,10 @@ import (
)
func TestReceivePack(t *testing.T) {
- gitalyAddress, _, cleanup := testserver.StartGitalyServer(t)
- defer cleanup()
+ gitalyAddress, _ := testserver.StartGitalyServer(t)
requests := requesthandlers.BuildAllowedWithGitalyHandlers(t, gitalyAddress)
- url, cleanup := testserver.StartHttpServer(t, requests)
- defer cleanup()
+ url := testserver.StartHttpServer(t, requests)
testCases := []struct {
username string
diff --git a/internal/command/receivepack/receivepack_test.go b/internal/command/receivepack/receivepack_test.go
index 44cb680..0f23492 100644
--- a/internal/command/receivepack/receivepack_test.go
+++ b/internal/command/receivepack/receivepack_test.go
@@ -16,23 +16,21 @@ import (
func TestForbiddenAccess(t *testing.T) {
requests := requesthandlers.BuildDisallowedByApiHandlers(t)
- cmd, _, cleanup := setup(t, "disallowed", requests)
- defer cleanup()
+ cmd, _ := setup(t, "disallowed", requests)
err := cmd.Execute(context.Background())
require.Equal(t, "Disallowed by API call", err.Error())
}
func TestCustomReceivePack(t *testing.T) {
- cmd, output, cleanup := setup(t, "1", requesthandlers.BuildAllowedWithCustomActionsHandlers(t))
- defer cleanup()
+ cmd, output := setup(t, "1", requesthandlers.BuildAllowedWithCustomActionsHandlers(t))
require.NoError(t, cmd.Execute(context.Background()))
require.Equal(t, "customoutput", output.String())
}
-func setup(t *testing.T, keyId string, requests []testserver.TestRequestHandler) (*Command, *bytes.Buffer, func()) {
- url, cleanup := testserver.StartSocketHttpServer(t, requests)
+func setup(t *testing.T, keyId string, requests []testserver.TestRequestHandler) (*Command, *bytes.Buffer) {
+ url := testserver.StartSocketHttpServer(t, requests)
output := &bytes.Buffer{}
input := bytes.NewBufferString("input")
@@ -43,5 +41,5 @@ func setup(t *testing.T, keyId string, requests []testserver.TestRequestHandler)
ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output, In: input},
}
- return cmd, output, cleanup
+ return cmd, output
}