error string starts with lowercase and do not contain trailing '.'

Signed-off-by: Minh-Quan TRAN <account@itscaro.me>
This commit is contained in:
Minh-Quan TRAN
2018-01-15 13:37:18 +01:00
committed by Alex Ellis
parent cadf7dea54
commit 6ec90d8ed0
9 changed files with 17 additions and 17 deletions

View File

@@ -69,7 +69,7 @@ func checkDestinationFiles(dir string, numberOfFiles, mode int) error {
return err return err
} }
if fileStat.Mode() != os.FileMode(mode) { if fileStat.Mode() != os.FileMode(mode) {
return errors.New("Expected mode did not match") return errors.New("expected mode did not match")
} }
} }

View File

@@ -265,10 +265,10 @@ func parseMap(envvars []string, keyName string) (map[string]string, error) {
envvarValue := s[1] envvarValue := s[1]
if !(len(envvarName) > 0) { 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) { 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 result[envvarName] = envvarValue

View File

@@ -47,7 +47,7 @@ Currently supported verbs: %v`, supportedVerbs)
var validURL = regexp.MustCompile(repositoryRegexpGithub + "|" + repositoryRegexpMockedServer) var validURL = regexp.MustCompile(repositoryRegexpGithub + "|" + repositoryRegexpMockedServer)
if !validURL.MatchString(args[1]) { if !validURL.MatchString(args[1]) {
return fmt.Errorf("The repository URL must be in the format https://github.com/<owner>/<repository>") return fmt.Errorf("the repository URL must be in the format https://github.com/<owner>/<repository>")
} }
} }
return nil return nil

View File

@@ -88,8 +88,8 @@ func Test_templatePull_error_not_valid_url(t *testing.T) {
faasCmd.SetOutput(&buf) faasCmd.SetOutput(&buf)
err := faasCmd.Execute() err := faasCmd.Execute()
if !strings.Contains(err.Error(), "The repository URL must be in the format https://github.com/<owner>/<repository>") { if !strings.Contains(err.Error(), "the repository URL must be in the format https://github.com/<owner>/<repository>") {
t.Fatal("Output does not contain the required string", err.Error()) t.Fatalf("Output does not contain the required string '%s'", err.Error())
} }
} }

View File

@@ -45,27 +45,27 @@ func translateLegacyOpts(args []string) ([]string, error) {
} }
if opt == "-action" { if opt == "-action" {
if len(optsCache) == idx+1 { 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 { if translated, ok := validActions[optsCache[idx+1]]; ok {
translatedArgs = append(translatedArgs, translated) translatedArgs = append(translatedArgs, translated)
optsCache = append(optsCache[:idx], optsCache[idx+2:]...) optsCache = append(optsCache[:idx], optsCache[idx+2:]...)
action = translated action = translated
} else { } 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"+"=") { if strings.HasPrefix(opt, "-action"+"=") {
s := strings.SplitN(opt, "=", 2) s := strings.SplitN(opt, "=", 2)
if len(s[1]) == 0 { 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 { if translated, ok := validActions[s[1]]; ok {
translatedArgs = append(translatedArgs, translated) translatedArgs = append(translatedArgs, translated)
optsCache = append(optsCache[:idx], optsCache[idx+1:]...) optsCache = append(optsCache[:idx], optsCache[idx+1:]...)
action = translated action = translated
} else { } 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])
} }
} }
} }

View File

@@ -65,7 +65,7 @@ func InvokeFunction(gateway string, name string, bytesIn *[]byte, contentType st
default: default:
bytesOut, err := ioutil.ReadAll(res.Body) bytesOut, err := ioutil.ReadAll(res.Body)
if err == nil { 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 { for _, queryValue := range query {
qs = qs + queryValue + "&" qs = qs + queryValue + "&"
if strings.Contains(queryValue, "=") == false { 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, "=") { 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, "&") qs = strings.TrimRight(qs, "&")

View File

@@ -49,7 +49,7 @@ func Test_InvokeFunction_Not2xx(t *testing.T) {
t.Fatalf("Error was not returned") 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()) { if !r.MatchString(err.Error()) {
t.Fatalf("Error not matched: %s", err) t.Fatalf("Error not matched: %s", err)
} }

View File

@@ -55,7 +55,7 @@ func ParseYAMLData(fileData []byte, regex string, filter string) (*Services, err
} }
if regexExists && filterExists { 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 { if regexExists || filterExists {
@@ -79,7 +79,7 @@ func ParseYAMLData(fileData []byte, regex string, filter string) (*Services, err
} }
if len(services.Functions) == 0 { 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")
} }
} }

View File

@@ -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" const invalidRegexErrorMsg string = "error parsing regexp"
var ParseYAMLTests_Regex = []struct { var ParseYAMLTests_Regex = []struct {