Merge pull request #35 from ravocean/trunk

Continued to work on the output of test file
This commit is contained in:
Husrav Homidov 2021-06-07 12:58:21 -07:00 committed by GitHub
commit 3dc66b9539
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 16 deletions

View file

@ -112,7 +112,7 @@ func openInBrowser(cmd *cobra.Command, opts *BrowseOptions) error {
baseRepo, err := opts.BaseRepo()
httpClient, _ := opts.HttpClient()
apiClient := api.NewClientFromHTTP(httpClient)
branchName, err := api.RepoDefaultBranch(apiClient, baseRepo)
branchName, _ := api.RepoDefaultBranch(apiClient, baseRepo)
if !inRepo(err) {
return printExit(exitNotInRepo, cmd, opts, "")

View file

@ -2,7 +2,7 @@ package browse
import (
"bytes"
"io/ioutil"
//"io/ioutil"
"net/http"
"testing"
@ -53,8 +53,8 @@ func runCommand(rt http.RoundTripper, t testCase) (*test.CmdOut, error) {
cmd.SetArgs(argv)
cmd.SetIn(&bytes.Buffer{})
cmd.SetOut(ioutil.Discard)
cmd.SetErr(ioutil.Discard)
cmd.SetOut(stdout)
cmd.SetErr(stderr)
_, err = cmd.ExecuteC()
return &test.CmdOut{
@ -76,16 +76,16 @@ func TestNewCmdBrowse(t *testing.T) {
stdoutExpected: "",
stderrExpected: "Error: accepts 1 flag, 2 flag(s) were recieved\nUse 'gh browse --help' for more information about browse\n\n",
},
{
name: "test2",
args: args{
repo: ghrepo.New("bchadwic", "cli"),
cli: "--settings",
},
errorExpected: false,
stdoutExpected: "hello world",
stderrExpected: "hello world",
},
// {
// name: "test2",
// args: args{
// repo: ghrepo.New("bchadwic", "cli"),
// cli: "--settings",
// },
// errorExpected: false,
// stdoutExpected: "hello world",
// stderrExpected: "hello world",
// },
}
for _, tt := range tests {
@ -103,9 +103,9 @@ func TestNewCmdBrowse(t *testing.T) {
assert.Error(t, err)
}
assert.Contains(t, output.String(), tt.stdoutExpected) // success outputs
assert.Contains(t, output.OutBuf.String(), tt.stdoutExpected) // success outputs
assert.Contains(t, output.Stderr(), tt.stderrExpected) // error outputs
assert.Contains(t, output.ErrBuf.String(), tt.stderrExpected) // error outputs
})
}