From a2bee1fad349093ca6300ae34986904270fa40e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 20 Jan 2021 14:48:14 +0100 Subject: [PATCH] :fire: utils.Spinner --- pkg/cmd/issue/view/view_test.go | 8 -------- pkg/cmd/pr/view/view_test.go | 8 -------- utils/utils.go | 16 ---------------- 3 files changed, 32 deletions(-) diff --git a/pkg/cmd/issue/view/view_test.go b/pkg/cmd/issue/view/view_test.go index 82890eac9..44e4d20f1 100644 --- a/pkg/cmd/issue/view/view_test.go +++ b/pkg/cmd/issue/view/view_test.go @@ -8,7 +8,6 @@ import ( "os/exec" "testing" - "github.com/briandowns/spinner" "github.com/cli/cli/internal/config" "github.com/cli/cli/internal/ghrepo" "github.com/cli/cli/internal/run" @@ -16,7 +15,6 @@ import ( "github.com/cli/cli/pkg/httpmock" "github.com/cli/cli/pkg/iostreams" "github.com/cli/cli/test" - "github.com/cli/cli/utils" "github.com/google/shlex" "github.com/stretchr/testify/assert" ) @@ -404,7 +402,6 @@ func TestIssueView_tty_Comments(t *testing.T) { } for name, tc := range tests { t.Run(name, func(t *testing.T) { - stubSpinner() http := &httpmock.Registry{} defer http.Verify(t) for name, file := range tc.fixtures { @@ -496,8 +493,3 @@ func TestIssueView_nontty_Comments(t *testing.T) { }) } } - -func stubSpinner() { - utils.StartSpinner = func(_ *spinner.Spinner) {} - utils.StopSpinner = func(_ *spinner.Spinner) {} -} diff --git a/pkg/cmd/pr/view/view_test.go b/pkg/cmd/pr/view/view_test.go index e61ccd614..8f3e7ae04 100644 --- a/pkg/cmd/pr/view/view_test.go +++ b/pkg/cmd/pr/view/view_test.go @@ -9,7 +9,6 @@ import ( "strings" "testing" - "github.com/briandowns/spinner" "github.com/cli/cli/context" "github.com/cli/cli/git" "github.com/cli/cli/internal/config" @@ -19,7 +18,6 @@ import ( "github.com/cli/cli/pkg/httpmock" "github.com/cli/cli/pkg/iostreams" "github.com/cli/cli/test" - "github.com/cli/cli/utils" "github.com/google/shlex" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -777,7 +775,6 @@ func TestPRView_tty_Comments(t *testing.T) { } for name, tt := range tests { t.Run(name, func(t *testing.T) { - stubSpinner() http := &httpmock.Registry{} defer http.Verify(t) for name, file := range tt.fixtures { @@ -873,8 +870,3 @@ func TestPRView_nontty_Comments(t *testing.T) { }) } } - -func stubSpinner() { - utils.StartSpinner = func(_ *spinner.Spinner) {} - utils.StopSpinner = func(_ *spinner.Spinner) {} -} diff --git a/utils/utils.go b/utils/utils.go index 4b58508ef..57b39b5ba 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -2,12 +2,10 @@ package utils import ( "fmt" - "io" "net/url" "strings" "time" - "github.com/briandowns/spinner" "github.com/cli/cli/internal/run" "github.com/cli/cli/pkg/browser" ) @@ -88,20 +86,6 @@ func Humanize(s string) string { return strings.Map(h, s) } -// We do this so we can stub out the spinner in tests -- it made things really flakey. This is not -// an elegant solution. -var StartSpinner = func(s *spinner.Spinner) { - s.Start() -} - -var StopSpinner = func(s *spinner.Spinner) { - s.Stop() -} - -func Spinner(w io.Writer) *spinner.Spinner { - return spinner.New(spinner.CharSets[11], 400*time.Millisecond, spinner.WithWriter(w)) -} - func IsURL(s string) bool { return strings.HasPrefix(s, "http:/") || strings.HasPrefix(s, "https:/") }