stretchr / testify

A toolkit with common assertions and mocks that plays nicely with the standard library
MIT License
22.52k stars 1.56k forks source link

`YAMLEq` does not validate YAML #1522

Closed phm07 closed 5 months ago

phm07 commented 6 months ago

YAMLEq does not check if passed strings have valid YAML syntax. This leads to the following test passing:

func TestYAML(t *testing.T) {
    json := `{ "foo": "bar", "baz": 42 }`
    assert.YAMLEq(t, json, json)
}

This is useful for the expected parameter, because it allows to check against JSON schemas, but IMO actual should be validated.

hendrywiranto commented 6 months ago

Hi!

as far as I know json is a valid yaml syntax reference

and for the code itself, it use yaml library and it return error when actual or expected is not a valid yaml based on the lib

so your case here is expected, hope this helps... cheers!