From 6ec90d8ed086dddb26fe3a0775975fba3a71e5a5 Mon Sep 17 00:00:00 2001 From: Minh-Quan TRAN Date: Mon, 15 Jan 2018 13:37:18 +0100 Subject: [PATCH] error string starts with lowercase and do not contain trailing '.' Signed-off-by: Minh-Quan TRAN --- builder/build_test.go | 2 +- commands/deploy.go | 4 ++-- commands/template_pull.go | 2 +- commands/template_pull_test.go | 4 ++-- legacy_cli.go | 8 ++++---- proxy/invoke.go | 6 +++--- proxy/invoke_test.go | 2 +- stack/stack.go | 4 ++-- stack/stack_test.go | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/builder/build_test.go b/builder/build_test.go index 4c7291c0..93e5990f 100644 --- a/builder/build_test.go +++ b/builder/build_test.go @@ -69,7 +69,7 @@ func checkDestinationFiles(dir string, numberOfFiles, mode int) error { return err } if fileStat.Mode() != os.FileMode(mode) { - return errors.New("Expected mode did not match") + return errors.New("expected mode did not match") } } diff --git a/commands/deploy.go b/commands/deploy.go index df525d93..cf36af18 100644 --- a/commands/deploy.go +++ b/commands/deploy.go @@ -265,10 +265,10 @@ func parseMap(envvars []string, keyName string) (map[string]string, error) { envvarValue := s[1] if !(len(envvarName) > 0) { - return nil, fmt.Errorf("Empty %s name: [%s]", keyName, envvar) + return nil, fmt.Errorf("empty %s name: [%s]", keyName, envvar) } if !(len(envvarValue) > 0) { - return nil, fmt.Errorf("Empty %s value: [%s]", keyName, envvar) + return nil, fmt.Errorf("empty %s value: [%s]", keyName, envvar) } result[envvarName] = envvarValue diff --git a/commands/template_pull.go b/commands/template_pull.go index 8e317ce2..0137f3d2 100644 --- a/commands/template_pull.go +++ b/commands/template_pull.go @@ -47,7 +47,7 @@ Currently supported verbs: %v`, supportedVerbs) var validURL = regexp.MustCompile(repositoryRegexpGithub + "|" + repositoryRegexpMockedServer) if !validURL.MatchString(args[1]) { - return fmt.Errorf("The repository URL must be in the format https://github.com//") + return fmt.Errorf("the repository URL must be in the format https://github.com//") } } return nil diff --git a/commands/template_pull_test.go b/commands/template_pull_test.go index 0ec5e555..0edc7e7d 100644 --- a/commands/template_pull_test.go +++ b/commands/template_pull_test.go @@ -88,8 +88,8 @@ func Test_templatePull_error_not_valid_url(t *testing.T) { faasCmd.SetOutput(&buf) err := faasCmd.Execute() - if !strings.Contains(err.Error(), "The repository URL must be in the format https://github.com//") { - t.Fatal("Output does not contain the required string", err.Error()) + if !strings.Contains(err.Error(), "the repository URL must be in the format https://github.com//") { + t.Fatalf("Output does not contain the required string '%s'", err.Error()) } } diff --git a/legacy_cli.go b/legacy_cli.go index cb717af1..eb8625d7 100644 --- a/legacy_cli.go +++ b/legacy_cli.go @@ -45,27 +45,27 @@ func translateLegacyOpts(args []string) ([]string, error) { } if opt == "-action" { if len(optsCache) == idx+1 { - return []string{""}, fmt.Errorf("No action supplied after deprecated -action flag") + return []string{""}, fmt.Errorf("no action supplied after deprecated -action flag") } if translated, ok := validActions[optsCache[idx+1]]; ok { translatedArgs = append(translatedArgs, translated) optsCache = append(optsCache[:idx], optsCache[idx+2:]...) action = translated } else { - return []string{""}, fmt.Errorf("Unknown action supplied to deprecated -action flag: %s", optsCache[idx+1]) + return []string{""}, fmt.Errorf("unknown action supplied to deprecated -action flag: %s", optsCache[idx+1]) } } if strings.HasPrefix(opt, "-action"+"=") { s := strings.SplitN(opt, "=", 2) if len(s[1]) == 0 { - return []string{""}, fmt.Errorf("No action supplied after deprecated -action= flag") + return []string{""}, fmt.Errorf("no action supplied after deprecated -action= flag") } if translated, ok := validActions[s[1]]; ok { translatedArgs = append(translatedArgs, translated) optsCache = append(optsCache[:idx], optsCache[idx+1:]...) action = translated } else { - return []string{""}, fmt.Errorf("Unknown action supplied to deprecated -action= flag: %s", s[1]) + return []string{""}, fmt.Errorf("unknown action supplied to deprecated -action= flag: %s", s[1]) } } } diff --git a/proxy/invoke.go b/proxy/invoke.go index 79ce2f59..3012fdaf 100644 --- a/proxy/invoke.go +++ b/proxy/invoke.go @@ -65,7 +65,7 @@ func InvokeFunction(gateway string, name string, bytesIn *[]byte, contentType st default: bytesOut, err := ioutil.ReadAll(res.Body) if err == nil { - return nil, fmt.Errorf("Server returned unexpected status code: %d - %s", res.StatusCode, string(bytesOut)) + return nil, fmt.Errorf("server returned unexpected status code: %d - %s", res.StatusCode, string(bytesOut)) } } @@ -80,10 +80,10 @@ func buildQueryString(query []string) (string, error) { for _, queryValue := range query { qs = qs + queryValue + "&" if strings.Contains(queryValue, "=") == false { - return "", fmt.Errorf("The --query flags must take the form of key=value (= not found)") + return "", fmt.Errorf("the --query flags must take the form of key=value (= not found)") } if strings.HasSuffix(queryValue, "=") { - return "", fmt.Errorf("The --query flag must take the form of: key=value (empty value given, or value ends in =)") + return "", fmt.Errorf("the --query flag must take the form of: key=value (empty value given, or value ends in =)") } } qs = strings.TrimRight(qs, "&") diff --git a/proxy/invoke_test.go b/proxy/invoke_test.go index 211e7502..8544fcd1 100644 --- a/proxy/invoke_test.go +++ b/proxy/invoke_test.go @@ -49,7 +49,7 @@ func Test_InvokeFunction_Not2xx(t *testing.T) { t.Fatalf("Error was not returned") } - r := regexp.MustCompile(`(?m:Server returned unexpected status code)`) + r := regexp.MustCompile(`(?m:server returned unexpected status code)`) if !r.MatchString(err.Error()) { t.Fatalf("Error not matched: %s", err) } diff --git a/stack/stack.go b/stack/stack.go index 0bbb27f6..ad39be52 100644 --- a/stack/stack.go +++ b/stack/stack.go @@ -55,7 +55,7 @@ func ParseYAMLData(fileData []byte, regex string, filter string) (*Services, err } if regexExists && filterExists { - return nil, fmt.Errorf("Pass in a regex or a filter, not both.") + return nil, fmt.Errorf("pass in a regex or a filter, not both") } if regexExists || filterExists { @@ -79,7 +79,7 @@ func ParseYAMLData(fileData []byte, regex string, filter string) (*Services, err } if len(services.Functions) == 0 { - return nil, fmt.Errorf("No functions matching --filter/--regex were found in the YAML file") + return nil, fmt.Errorf("no functions matching --filter/--regex were found in the YAML file") } } diff --git a/stack/stack_test.go b/stack/stack_test.go index 35b4882f..41b6b4ae 100644 --- a/stack/stack_test.go +++ b/stack/stack_test.go @@ -50,7 +50,7 @@ const TestData_2 string = `provider: ` -const noMatchesErrorMsg string = "No functions matching --filter/--regex were found in the YAML file" +const noMatchesErrorMsg string = "no functions matching --filter/--regex were found in the YAML file" const invalidRegexErrorMsg string = "error parsing regexp" var ParseYAMLTests_Regex = []struct {