Skip to content
Merged
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. No test for HasRunBrevShell: false with HasRunBrevOpen: false. Minor — you test nil and {Open: true, Shell: false}, but not the zero-value &OnboardingObject{} case (both false). Would make the table more complete:
    {
    name: "zeroValue",
    res: &OnboardingObject{},
    want: false,
    },

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