-
Notifications
You must be signed in to change notification settings - Fork 229
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
Print error message when no matches are found by --filter or --regex flag #125
Conversation
Thank you for your contribution. I've just checked and your commit doesn't appear to be signed-off. |
Just added some extra test functionality, to test that when we expect an error message was returned, to verify that it is the correct error message. |
@@ -66,7 +66,6 @@ func ParseYAMLData(fileData []byte, regex string, filter string) (*Services, err | |||
if regexExists { | |||
match, err = regexp.MatchString(regex, function.Name) | |||
if err != nil { | |||
fmt.Printf("Invalid regex passed to --regex option\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message was deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already an error thrown by the regex parser when the regex is invalid, which gets printed out by each command which calls ParseYAMLFile()
by its following error checking block:
if err != nil {
log.Fataln(err.Error())
return
}
The line that log.Fataln(err)
prints is error parsing regexp:
if it's a regex error, so I figured this printf is redundant. Also, for testing, I wanted to confirm the error message, and only have one line print out makes that easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as you bubble up the error.
Very good improvement to the UX here @ericstoekl |
Can you include the expected messages for given error scenarios below? |
Expected errors so far:
For example, if I use the command
These are the only two errors I've encountered so far related to |
Great. Can you now squash your commits or at least sign all of them?
|
60d308c
to
3effbf1
Compare
stack/stack_test.go
Outdated
searchTerm: "node", | ||
functions: []string{"nodejs-echo"}, | ||
file: TestData_1, | ||
expectError: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could get rid of the expectedErrorMsg
and change expectError
to a string, use len(test.expectError) > 0
for the conditional - avoids having the redundant variable since you're always checking for the message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks John, will update this evening.
stack/stack_test.go
Outdated
strkeys, | ||
test.functions, | ||
) | ||
if test.expectError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See earlier comment if len(test.expectError) > 0 {
…flag Improve tests for --filter and --regex Signed-off-by: Eric Stoekl <ems5311@gmail.com>
3effbf1
to
7f0ec9f
Compare
Addressed the suggestions from @johnmccabe , and squashed the commits |
LGTM |
Print error message when no matches are found by --filter or --regex flag
Signed-off-by: Eric Stoekl ems5311@gmail.com
Description
This change is to return an error message when all functions are filtered out by the --filter or --regex option. The current error message is
"No functions found in YAML, check --filter/--regex"
.Motivation and Context
Issue Print error message when --filter or --regex returns no matches #124
This will help users figure out what is wrong with their command if they expect functions to be deployed, and nothing happens.
How Has This Been Tested?
Tests were upgraded to accommodate this change and check for this error to be properly thrown when --filter and --regex remove all functions.
Types of changes
Checklist:
git commit -s