-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More evaluation tests / consistent user attribute conversions (#71)
* Add more evaluation tests / align user attribute conversions * Bump version * Replace codecov with sonar * Update go-ci.yml * Fixup evaluation error handling * Specify error types * More tests
- Loading branch information
Showing
24 changed files
with
3,246 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package configcat | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// ErrKeyNotFound is returned when a key is not found in the configuration. | ||
type ErrKeyNotFound struct { | ||
Key string | ||
AvailableKeys []string | ||
} | ||
|
||
func (e ErrKeyNotFound) Error() string { | ||
var availableKeys = "" | ||
if len(e.AvailableKeys) > 0 { | ||
availableKeys = "'" + strings.Join(e.AvailableKeys, "', '") + "'" | ||
} | ||
return fmt.Sprintf( | ||
"failed to evaluate setting '%s' (the key was not found in config JSON); available keys: [%s]", | ||
e.Key, | ||
availableKeys, | ||
) | ||
} | ||
|
||
// ErrSettingTypeMismatch is returned when a requested setting type doesn't match with the expected type. | ||
type ErrSettingTypeMismatch struct { | ||
Key string | ||
Value interface{} | ||
ExpectedType string | ||
} | ||
|
||
func (e ErrSettingTypeMismatch) Error() string { | ||
return fmt.Sprintf( | ||
"the type of the setting '%s' doesn't match with the expected type; setting's type was '%T' but the expected type was '%s'", | ||
e.Key, | ||
e.Value, | ||
e.ExpectedType, | ||
) | ||
} | ||
|
||
// ErrConfigJsonMissing is returned when the config JSON is empty or missing. | ||
type ErrConfigJsonMissing struct { | ||
Key string | ||
} | ||
|
||
func (e ErrConfigJsonMissing) Error() string { | ||
return fmt.Sprintf( | ||
"config JSON is not present when evaluating setting '%s'; returning the `defaultValue` parameter that you specified in your application", | ||
e.Key, | ||
) | ||
} |
Oops, something went wrong.