Skip to content

Commit 5fb5d41

Browse files
authored
Merge pull request cli#28 from ravocean/trunk
Starter code for testing
2 parents 798e03c + 6391bf5 commit 5fb5d41

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

pkg/cmd/browse/browse_test.go

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/cli/cli/pkg/iostreams"
1313
"github.com/cli/cli/test"
1414
"github.com/google/shlex"
15+
"github.com/spf13/cobra"
1516
)
1617

1718
func TestNewCmdBrowse(t *testing.T) {
@@ -65,10 +66,51 @@ func TestBrowseOpen(t *testing.T) {
6566

6667
func Test_browseList(t *testing.T) {
6768
type args struct {
68-
repo ghrepo.Interface
69-
cli string
70-
expectedOutputs string
69+
repo ghrepo.Interface
70+
cli string
7171
}
7272
tests := []struct {
73+
name string
74+
args args
75+
urlExpected string
76+
exitExpected exitCode
7377
}{}
78+
for _, test := range tests {
79+
80+
}
81+
}
82+
83+
func createCommand(repo ghrepo.Interface, cli string) *cobra.Command {
84+
io, _, stdout, stderr := iostreams.Test()
85+
io.SetStdoutTTY(false)
86+
io.SetStdinTTY(false) // Ask the team about TTY
87+
io.SetStderrTTY(false)
88+
89+
factory := &cmdutil.Factory{
90+
IOStreams: io,
91+
Config: func() (config.Config, error) {
92+
return config.NewBlankConfig(), nil
93+
},
94+
BaseRepo: func() (ghrepo.Interface, error) {
95+
return ghrepo.New("OWNER", "REPO"), nil
96+
},
97+
}
98+
99+
cmd := NewCmdView(factory, nil)
100+
101+
argv, err := shlex.Split(cli)
102+
if err != nil {
103+
return nil, err
104+
}
105+
cmd.SetArgs(argv)
106+
107+
cmd.SetIn(&bytes.Buffer{})
108+
cmd.SetOut(ioutil.Discard)
109+
cmd.SetErr(ioutil.Discard)
110+
111+
_, err = cmd.ExecuteC()
112+
return &test.CmdOut{
113+
OutBuf: stdout,
114+
ErrBuf: stderr,
115+
}, err
74116
}

0 commit comments

Comments
 (0)