Skip to content

Commit

Permalink
Update error message for missing application (#6281)
Browse files Browse the repository at this point in the history
# Description

Adds an additional error message to `rad resource list`.

## Type of change

<!--

Please select **one** of the following options that describes your
change and delete the others. Clearly identifying the type of change you
are making will help us review your PR faster, and is used in authoring
release notes.

If you are making a bug fix or functionality change to Radius and do not
have an associated issue link please create one now.

-->

- This pull request adds or changes features of Radius and has an
approved issue (issue link required).

<!--

Please update the following to link the associated issue. This is
required for some kinds of changes (see above).

-->

Fixes: #6236

## Auto-generated summary

<!--
GitHub Copilot for docs will auto-generate a summary of the PR
-->

<!--
copilot:all
-->
### <samp>🤖 Generated by Copilot at 4cbfd98</samp>

### Summary
🧪📝🚀

<!--
1.  🧪 for updating the test case
2.  📝 for adding a more helpful error message
3.  🚀 for improving the user experience of the CLI
-->
Improve error handling and testing for `resource list` command. Add a
clearer error message for invalid applications and update the
corresponding test case.

> _`Run` test updated_
> _Error message more helpful_
> _Autumn of bug fixes_

### Walkthrough
* Improve error message for invalid application name in `list` command
([link](https://github.com/radius-project/radius/pull/6281/files?diff=unified&w=0#diff-b21dcd67dbc0d24e0f8bba90701dfcfb5736cf40427547c7a7ccb91478f262cfL160-R160))
* Update test case for `Run` function in `list_test.go` to match new
error message
([link](https://github.com/radius-project/radius/pull/6281/files?diff=unified&w=0#diff-d57c4c1535dd3783fc94937211b66a786a621683678bcefdef775626c9e22c5eL125-R125))
  • Loading branch information
AaronCrawfis authored Sep 18, 2023
1 parent dc1a49d commit 9511b04
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/cli/cmd/resource/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (r *Runner) Run(ctx context.Context) error {
} else {
_, err = client.ShowApplication(ctx, r.ApplicationName)
if clients.Is404Error(err) {
return clierrors.Message("The application %q could not be found in workspace %q.", r.ApplicationName, r.Workspace.Name)
return clierrors.Message("The application %q could not be found in workspace %q. Make sure you specify the correct application with '-a/--application' or switch applications with 'rad app switch'.", r.ApplicationName, r.Workspace.Name)
} else if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/cmd/resource/list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func Test_Run(t *testing.T) {

err := runner.Run(context.Background())
require.Error(t, err)
require.IsType(t, err, clierrors.Message("The application %q could not be found in workspace %q.", "test-app", radcli.TestWorkspaceName))
require.IsType(t, err, clierrors.Message("The application %q could not be found in workspace %q. Make sure you specify the correct application with '-a/--application' or switch applications with 'rad app switch'.", "test-app", radcli.TestWorkspaceName))
})

t.Run("Success", func(t *testing.T) {
Expand Down

0 comments on commit 9511b04

Please sign in to comment.