summaryrefslogtreecommitdiff
path: root/go/internal/command/discover/discover_test.go
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2019-03-14 14:01:42 +0100
committerBob Van Landuyt <bob@vanlanduyt.co>2019-03-15 18:03:35 +0100
commit83c0f18e1de04b3bad9c424084e738e911c47336 (patch)
tree22d69b9450693bb153e58dbe8b7cd6feb3f8e1e0 /go/internal/command/discover/discover_test.go
parent53511f3655a5eed9976164fbd88d14df3490000c (diff)
downloadgitlab-shell-83c0f18e1de04b3bad9c424084e738e911c47336.tar.gz
Wrap Stderr & Stdout in a reporter struct
The reporter struct can be used for passing around and reporting to the io.Writer of choice.
Diffstat (limited to 'go/internal/command/discover/discover_test.go')
-rw-r--r--go/internal/command/discover/discover_test.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/go/internal/command/discover/discover_test.go b/go/internal/command/discover/discover_test.go
index 752e76e..ec6f931 100644
--- a/go/internal/command/discover/discover_test.go
+++ b/go/internal/command/discover/discover_test.go
@@ -11,6 +11,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/command/commandargs"
+ "gitlab.com/gitlab-org/gitlab-shell/go/internal/command/reporting"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/gitlabnet/testserver"
)
@@ -78,11 +79,10 @@ func TestExecute(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
- buffer := &bytes.Buffer{}
- output = buffer
cmd := &Command{Config: testConfig, Args: tc.arguments}
+ buffer := &bytes.Buffer{}
- err := cmd.Execute()
+ err := cmd.Execute(&reporting.Reporter{Out: buffer})
assert.NoError(t, err)
assert.Equal(t, tc.expectedOutput, buffer.String())
@@ -120,11 +120,12 @@ func TestFailingExecute(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
cmd := &Command{Config: testConfig, Args: tc.arguments}
+ buffer := &bytes.Buffer{}
- err := cmd.Execute()
+ err := cmd.Execute(&reporting.Reporter{Out: buffer})
+ assert.Empty(t, buffer.String())
assert.EqualError(t, err, tc.expectedError)
})
}
-
}