summaryrefslogtreecommitdiff
path: root/internal/command/shared
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/shared
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/shared')
-rw-r--r--internal/command/shared/accessverifier/accessverifier_test.go12
-rw-r--r--internal/command/shared/customaction/customaction_test.go6
2 files changed, 7 insertions, 11 deletions
diff --git a/internal/command/shared/accessverifier/accessverifier_test.go b/internal/command/shared/accessverifier/accessverifier_test.go
index 8ad87b8..8e0b5f9 100644
--- a/internal/command/shared/accessverifier/accessverifier_test.go
+++ b/internal/command/shared/accessverifier/accessverifier_test.go
@@ -22,7 +22,7 @@ var (
action = commandargs.ReceivePack
)
-func setup(t *testing.T) (*Command, *bytes.Buffer, *bytes.Buffer, func()) {
+func setup(t *testing.T) (*Command, *bytes.Buffer, *bytes.Buffer) {
requests := []testserver.TestRequestHandler{
{
Path: "/api/v4/internal/allowed",
@@ -50,7 +50,7 @@ func setup(t *testing.T) (*Command, *bytes.Buffer, *bytes.Buffer, func()) {
},
}
- url, cleanup := testserver.StartSocketHttpServer(t, requests)
+ url := testserver.StartSocketHttpServer(t, requests)
errBuf := &bytes.Buffer{}
outBuf := &bytes.Buffer{}
@@ -58,12 +58,11 @@ func setup(t *testing.T) (*Command, *bytes.Buffer, *bytes.Buffer, func()) {
readWriter := &readwriter.ReadWriter{Out: outBuf, ErrOut: errBuf}
cmd := &Command{Config: &config.Config{GitlabUrl: url}, ReadWriter: readWriter}
- return cmd, errBuf, outBuf, cleanup
+ return cmd, errBuf, outBuf
}
func TestMissingUser(t *testing.T) {
- cmd, _, _, cleanup := setup(t)
- defer cleanup()
+ cmd, _, _ := setup(t)
cmd.Args = &commandargs.Shell{GitlabKeyId: "2"}
_, err := cmd.Verify(context.Background(), action, repo)
@@ -72,8 +71,7 @@ func TestMissingUser(t *testing.T) {
}
func TestConsoleMessages(t *testing.T) {
- cmd, errBuf, outBuf, cleanup := setup(t)
- defer cleanup()
+ cmd, errBuf, outBuf := setup(t)
cmd.Args = &commandargs.Shell{GitlabKeyId: "1"}
cmd.Verify(context.Background(), action, repo)
diff --git a/internal/command/shared/customaction/customaction_test.go b/internal/command/shared/customaction/customaction_test.go
index 119da5b..87ae2e4 100644
--- a/internal/command/shared/customaction/customaction_test.go
+++ b/internal/command/shared/customaction/customaction_test.go
@@ -54,8 +54,7 @@ func TestExecuteEOFSent(t *testing.T) {
},
}
- url, cleanup := testserver.StartSocketHttpServer(t, requests)
- defer cleanup()
+ url := testserver.StartSocketHttpServer(t, requests)
outBuf := &bytes.Buffer{}
errBuf := &bytes.Buffer{}
@@ -124,8 +123,7 @@ func TestExecuteNoEOFSent(t *testing.T) {
},
}
- url, cleanup := testserver.StartSocketHttpServer(t, requests)
- defer cleanup()
+ url := testserver.StartSocketHttpServer(t, requests)
outBuf := &bytes.Buffer{}
errBuf := &bytes.Buffer{}