Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion assert/assertion_format.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 26 additions & 2 deletions assert/assertion_forward.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion assert/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,19 @@ func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{
return Equal(t, expectedJSONAsInterface, actualJSONAsInterface, msgAndArgs...)
}

// YAMLEq asserts that two YAML strings are equivalent.
// YAMLEq asserts that the first documents in the two YAML strings are equivalent.
Comment thread
ccoVeille marked this conversation as resolved.
//
// expected := `---
// key: value
// ---
// key: this is a second document, it is not evaluated
// `
// actual := `---
// key: value
// ---
// key: this is a subsequent document, it is not evaluated
// `
// assert.YAMLEq(t, expected, actual)
func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
Expand Down
25 changes: 25 additions & 0 deletions assert/assertions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2852,6 +2852,31 @@ func TestYAMLEq_ArraysOfDifferentOrder(t *testing.T) {
False(t, YAMLEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`))
}

func TestYAMLEq_OnlyFirstDocument(t *testing.T) {
t.Parallel()

mockT := new(testing.T)
True(t, YAMLEq(mockT,
`---
doc1: same
---
doc2: different
`,
`---
doc1: same
---
doc2: notsame
`,
))
}

func TestYAMLEq_InvalidIdenticalYAML(t *testing.T) {
t.Parallel()

mockT := new(testing.T)
False(t, YAMLEq(mockT, `}`, `}`))
}

type diffTestingStruct struct {
A string
B int
Expand Down
28 changes: 26 additions & 2 deletions require/require.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 26 additions & 2 deletions require/require_forward.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.