Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): env ls should work if not in copilot dir #1021

Merged
merged 2 commits into from
Jun 15, 2020
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
11 changes: 0 additions & 11 deletions internal/pkg/cli/env_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ func newListEnvOpts(vars listEnvVars) (*listEnvOpts, error) {
}, nil
}

// Validate returns an error if the values passed by flags are invalid.
func (o *listEnvOpts) Validate() error {
if o.AppName() == "" {
return fmt.Errorf("no application found: run %s or %s into your workspace please", color.HighlightCode("app init"), color.HighlightCode("cd"))
}
return nil
}

// Ask asks for fields that are required but not passed in.
func (o *listEnvOpts) Ask() error {
if o.AppName() != "" {
Expand Down Expand Up @@ -135,9 +127,6 @@ func BuildEnvListCmd() *cobra.Command {
if err != nil {
return err
}
if err := opts.Validate(); err != nil {
return err
}
if err := opts.Ask(); err != nil {
return err
}
Expand Down
38 changes: 0 additions & 38 deletions internal/pkg/cli/env_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,6 @@ import (
"github.com/stretchr/testify/require"
)

func TestListEnvOpts_Validate(t *testing.T) {
testCases := map[string]struct {
inAppName string

wantedErr string
}{
"valid app": {
inAppName: "phonetool",
},
"invalid app": {
inAppName: "",

wantedErr: fmt.Sprint("no application found: run `app init` or `cd` into your workspace please"),
},
}

for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
// GIVEN
opts := &initEnvOpts{
initEnvVars: initEnvVars{
GlobalOpts: &GlobalOpts{appName: tc.inAppName},
},
}

// WHEN
err := opts.Validate()

// THEN
if tc.wantedErr != "" {
require.EqualError(t, err, tc.wantedErr)
} else {
require.Nil(t, err)
}
})
}
}

func TestEnvList_Ask(t *testing.T) {
testCases := map[string]struct {
inputApp string
Expand Down