File tree Expand file tree Collapse file tree 2 files changed +24
-6
lines changed
Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,11 @@ package list
22
33import (
44 "bytes"
5+ "io/ioutil"
56 "testing"
67
78 "github.com/cli/cli/pkg/cmdutil"
9+ "github.com/cli/cli/pkg/iostreams"
810 "github.com/google/shlex"
911 "github.com/stretchr/testify/assert"
1012)
@@ -13,6 +15,7 @@ func TestNewCmdList(t *testing.T) {
1315 tests := []struct {
1416 name string
1517 cli string
18+ tty bool
1619 wants ListOptions
1720 wantsErr bool
1821 }{
@@ -38,7 +41,13 @@ func TestNewCmdList(t *testing.T) {
3841
3942 for _ , tt := range tests {
4043 t .Run (tt .name , func (t * testing.T ) {
41- f := & cmdutil.Factory {}
44+ io , _ , _ , _ := iostreams .Test ()
45+ io .SetStdinTTY (tt .tty )
46+ io .SetStdoutTTY (tt .tty )
47+
48+ f := & cmdutil.Factory {
49+ IOStreams : io ,
50+ }
4251
4352 argv , err := shlex .Split (tt .cli )
4453 assert .NoError (t , err )
@@ -50,8 +59,8 @@ func TestNewCmdList(t *testing.T) {
5059 })
5160 cmd .SetArgs (argv )
5261 cmd .SetIn (& bytes.Buffer {})
53- cmd .SetOut (& bytes. Buffer {} )
54- cmd .SetErr (& bytes. Buffer {} )
62+ cmd .SetOut (ioutil . Discard )
63+ cmd .SetErr (ioutil . Discard )
5564
5665 _ , err = cmd .ExecuteC ()
5766 if tt .wantsErr {
Original file line number Diff line number Diff line change @@ -2,9 +2,11 @@ package view
22
33import (
44 "bytes"
5+ "io/ioutil"
56 "testing"
67
78 "github.com/cli/cli/pkg/cmdutil"
9+ "github.com/cli/cli/pkg/iostreams"
810 "github.com/google/shlex"
911 "github.com/stretchr/testify/assert"
1012)
@@ -13,6 +15,7 @@ func TestNewCmdView(t *testing.T) {
1315 tests := []struct {
1416 name string
1517 cli string
18+ tty bool
1619 wants ViewOptions
1720 wantsErr bool
1821 }{
@@ -31,7 +34,13 @@ func TestNewCmdView(t *testing.T) {
3134
3235 for _ , tt := range tests {
3336 t .Run (tt .name , func (t * testing.T ) {
34- f := & cmdutil.Factory {}
37+ io , _ , _ , _ := iostreams .Test ()
38+ io .SetStdinTTY (tt .tty )
39+ io .SetStdoutTTY (tt .tty )
40+
41+ f := & cmdutil.Factory {
42+ IOStreams : io ,
43+ }
3544
3645 argv , err := shlex .Split (tt .cli )
3746 assert .NoError (t , err )
@@ -43,8 +52,8 @@ func TestNewCmdView(t *testing.T) {
4352 })
4453 cmd .SetArgs (argv )
4554 cmd .SetIn (& bytes.Buffer {})
46- cmd .SetOut (& bytes. Buffer {} )
47- cmd .SetErr (& bytes. Buffer {} )
55+ cmd .SetOut (ioutil . Discard )
56+ cmd .SetErr (ioutil . Discard )
4857
4958 _ , err = cmd .ExecuteC ()
5059 if tt .wantsErr {
You can’t perform that action at this time.
0 commit comments