Enable tests to capture spinner output
Explicitly assign the writer stream for the progress spinner so that tests may override it. The default when not in testing stays the same: the output stream is the colorable stdout.
This commit is contained in:
parent
2660561ed9
commit
488b47bded
2 changed files with 6 additions and 3 deletions
|
|
@ -295,7 +295,7 @@ func repoFork(cmd *cobra.Command, args []string) error {
|
|||
|
||||
greenCheck := utils.Green("✓")
|
||||
out := colorableOut(cmd)
|
||||
s := utils.Spinner()
|
||||
s := utils.Spinner(out)
|
||||
loading := utils.Gray("Forking ") + utils.Bold(utils.Gray(ghrepo.FullName(toFork))) + utils.Gray("...")
|
||||
s.Suffix = " " + loading
|
||||
s.FinalMSG = utils.Gray(fmt.Sprintf("- %s\n", loading))
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package utils
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -68,6 +69,8 @@ func Humanize(s string) string {
|
|||
return strings.Map(h, s)
|
||||
}
|
||||
|
||||
func Spinner() *spinner.Spinner {
|
||||
return spinner.New(spinner.CharSets[11], 400*time.Millisecond)
|
||||
func Spinner(w io.Writer) *spinner.Spinner {
|
||||
s := spinner.New(spinner.CharSets[11], 400*time.Millisecond)
|
||||
s.Writer = w
|
||||
return s
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue