Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions pkg/cmd/hello/hello_test.go
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
package hello

import "testing"

type shellOnboardingPollDoneCase struct {
name string
res *OnboardingObject
want bool
}

var shellOnboardingPollDoneCases = []shellOnboardingPollDoneCase{
{
name: "hasRunBrevShell",
res: &OnboardingObject{HasRunBrevShell: true},
want: true,
},
{
name: "brevOpenOnly",
res: &OnboardingObject{HasRunBrevOpen: true, HasRunBrevShell: false},
want: false,
},
{
name: "nil",
res: nil,
want: false,
},
}

func TestShellOnboardingPollDone(t *testing.T) {
t.Parallel()
for _, c := range shellOnboardingPollDoneCases {
t.Run(c.name, func(t *testing.T) {
t.Parallel()
if got := shellOnboardingPollDone(c.res); got != c.want {
t.Fatalf("got %v, want %v", got, c.want)
}
})
}
}
4 changes: 4 additions & 0 deletions pkg/cmd/hello/onboarding_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ type OnboardingObject struct {
HasRunBrevOpen bool `json:"hasRunBrevOpen"`
}

func shellOnboardingPollDone(res *OnboardingObject) bool {
return res != nil && res.HasRunBrevShell
}

func SetupDefaultOnboardingFile() error {
// get path
path, err := GetOnboardingFilePath()
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/hello/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func doBrevShellOnboarding(
if err1 != nil {
return breverrors.WrapAndTrace(err1)
}
if res.HasRunBrevOpen {
if shellOnboardingPollDone(res) {
spinner.Suffix = spinnerSuffix
time.Sleep(250 * time.Millisecond)
spinner.Stop()
Expand Down
Loading