fix(utils): use lower case in error messages (#2144)

pull/1991/head^2
Clément Michaud 2021-07-04 00:08:24 +02:00 committed by GitHub
parent 907680c035
commit 2dbd7ed219
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 15 additions and 15 deletions

View File

@ -334,7 +334,7 @@ func (suite *LDAPAuthenticationBackendSuite) TestShouldRaiseOnBadRefreshInterval
suite.Assert().False(suite.validator.HasWarnings())
suite.Require().Len(suite.validator.Errors(), 1)
suite.Assert().EqualError(suite.validator.Errors()[0], "Auth Backend `refresh_interval` is configured to 'blah' but it must be either a duration notation or one of 'disable', or 'always'. Error from parser: Could not convert the input string of blah into a duration")
suite.Assert().EqualError(suite.validator.Errors()[0], "Auth Backend `refresh_interval` is configured to 'blah' but it must be either a duration notation or one of 'disable', or 'always'. Error from parser: could not convert the input string of blah into a duration")
}
func (suite *LDAPAuthenticationBackendSuite) TestShouldSetDefaultImplementation() {

View File

@ -54,6 +54,6 @@ func TestShouldRaiseErrorOnBadDurationStrings(t *testing.T) {
ValidateRegulation(&config, validator)
assert.Len(t, validator.Errors(), 2)
assert.EqualError(t, validator.Errors()[0], "Error occurred parsing regulation find_time string: Could not convert the input string of a year into a duration")
assert.EqualError(t, validator.Errors()[1], "Error occurred parsing regulation ban_time string: Could not convert the input string of forever into a duration")
assert.EqualError(t, validator.Errors()[0], "Error occurred parsing regulation find_time string: could not convert the input string of a year into a duration")
assert.EqualError(t, validator.Errors()[1], "Error occurred parsing regulation ban_time string: could not convert the input string of forever into a duration")
}

View File

@ -430,8 +430,8 @@ func TestShouldRaiseErrorWhenBadInactivityAndExpirationSet(t *testing.T) {
assert.False(t, validator.HasWarnings())
assert.Len(t, validator.Errors(), 2)
assert.EqualError(t, validator.Errors()[0], "Error occurred parsing session expiration string: Could not convert the input string of -1 into a duration")
assert.EqualError(t, validator.Errors()[1], "Error occurred parsing session inactivity string: Could not convert the input string of -1 into a duration")
assert.EqualError(t, validator.Errors()[0], "Error occurred parsing session expiration string: could not convert the input string of -1 into a duration")
assert.EqualError(t, validator.Errors()[1], "Error occurred parsing session inactivity string: could not convert the input string of -1 into a duration")
}
func TestShouldRaiseErrorWhenBadRememberMeDurationSet(t *testing.T) {
@ -443,7 +443,7 @@ func TestShouldRaiseErrorWhenBadRememberMeDurationSet(t *testing.T) {
assert.False(t, validator.HasWarnings())
assert.Len(t, validator.Errors(), 1)
assert.EqualError(t, validator.Errors()[0], "Error occurred parsing session remember_me_duration string: Could not convert the input string of 1 year into a duration")
assert.EqualError(t, validator.Errors()[0], "Error occurred parsing session remember_me_duration string: could not convert the input string of 1 year into a duration")
}
func TestShouldSetDefaultRememberMeDuration(t *testing.T) {

View File

@ -19,7 +19,7 @@ func CheckUntil(interval time.Duration, timeout time.Duration, predicate func()
return err
}
case <-time.After(timeout):
return fmt.Errorf("Timeout of %ds reached", int64(timeout/time.Second))
return fmt.Errorf("timeout of %ds reached", int64(timeout/time.Second))
}
}
}

View File

@ -179,5 +179,5 @@ func RunFuncWithRetry(attempts int, sleep time.Duration, f func() error) (err er
log.Printf("Retrying after error: %s", err)
}
return fmt.Errorf("Failed after %d attempts, last error: %s", attempts, err)
return fmt.Errorf("failed after %d attempts, last error: %s", attempts, err)
}

View File

@ -79,5 +79,5 @@ func ParseRsaPublicKeyFromPemStr(pubPEM string) (*rsa.PublicKey, error) {
break // fall through
}
return nil, errors.New("Key type is not RSA")
return nil, errors.New("key type is not RSA")
}

View File

@ -38,13 +38,13 @@ func ParseDurationString(input string) (time.Duration, error) {
case input == "0" || len(matches) == 3:
seconds, err := strconv.Atoi(input)
if err != nil {
return 0, fmt.Errorf("Could not convert the input string of %s into a duration: %s", input, err)
return 0, fmt.Errorf("could not convert the input string of %s into a duration: %s", input, err)
}
duration = time.Duration(seconds) * time.Second
case input != "":
// Throw this error if input is anything other than a blank string, blank string will default to a duration of nothing
return 0, fmt.Errorf("Could not convert the input string of %s into a duration", input)
return 0, fmt.Errorf("could not convert the input string of %s into a duration", input)
}
return duration, nil

View File

@ -47,25 +47,25 @@ func TestShouldParseSecondsString(t *testing.T) {
func TestShouldNotParseDurationStringWithOutOfOrderQuantitiesAndUnits(t *testing.T) {
duration, err := ParseDurationString("h1")
assert.EqualError(t, err, "Could not convert the input string of h1 into a duration")
assert.EqualError(t, err, "could not convert the input string of h1 into a duration")
assert.Equal(t, time.Duration(0), duration)
}
func TestShouldNotParseBadDurationString(t *testing.T) {
duration, err := ParseDurationString("10x")
assert.EqualError(t, err, "Could not convert the input string of 10x into a duration")
assert.EqualError(t, err, "could not convert the input string of 10x into a duration")
assert.Equal(t, time.Duration(0), duration)
}
func TestShouldNotParseDurationStringWithMultiValueUnits(t *testing.T) {
duration, err := ParseDurationString("10ms")
assert.EqualError(t, err, "Could not convert the input string of 10ms into a duration")
assert.EqualError(t, err, "could not convert the input string of 10ms into a duration")
assert.Equal(t, time.Duration(0), duration)
}
func TestShouldNotParseDurationStringWithLeadingZero(t *testing.T) {
duration, err := ParseDurationString("005h")
assert.EqualError(t, err, "Could not convert the input string of 005h into a duration")
assert.EqualError(t, err, "could not convert the input string of 005h into a duration")
assert.Equal(t, time.Duration(0), duration)
}