mirror of
https://github.com/stretchr/testify.git
synced 2025-05-31 11:42:44 +00:00
assert.YAMLEq: shortcut if same strings
Shortcut in assert.YAMLEq once we have validated that 'expected' is valid YAML, and 'actual' is the exact same string.
This commit is contained in:
parent
4eb688ba0c
commit
4f71159ca8
@ -1876,6 +1876,11 @@ func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{
|
||||
return Fail(t, fmt.Sprintf("Expected value ('%s') is not valid yaml.\nYAML parsing error: '%s'", expected, err.Error()), msgAndArgs...)
|
||||
}
|
||||
|
||||
// Shortcut if same bytes
|
||||
if actual == expected {
|
||||
return true
|
||||
}
|
||||
|
||||
if err := yaml.Unmarshal([]byte(actual), &actualYAMLAsInterface); err != nil {
|
||||
return Fail(t, fmt.Sprintf("Input ('%s') needs to be valid yaml.\nYAML error: '%s'", actual, err.Error()), msgAndArgs...)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user