@@ -12,7 +12,7 @@ import (
1212func TestRequireYAMLEqWrapper_EqualYAMLString (t * testing.T ) {
1313 t .Parallel ()
1414
15- mock := new (MockT )
15+ mock := new (mockT )
1616 mockRequire := target .New (mock )
1717
1818 mockRequire .YAMLEq (`{"hello": "world", "foo": "bar"}` , `{"hello": "world", "foo": "bar"}` )
@@ -24,7 +24,7 @@ func TestRequireYAMLEqWrapper_EqualYAMLString(t *testing.T) {
2424func TestRequireYAMLEqWrapper_EquivalentButNotEqual (t * testing.T ) {
2525 t .Parallel ()
2626
27- mock := new (MockT )
27+ mock := new (mockT )
2828 mockRequire := target .New (mock )
2929
3030 mockRequire .YAMLEq (`{"hello": "world", "foo": "bar"}` , `{"foo": "bar", "hello": "world"}` )
@@ -36,7 +36,7 @@ func TestRequireYAMLEqWrapper_EquivalentButNotEqual(t *testing.T) {
3636func TestRequireYAMLEqWrapper_HashOfArraysAndHashes (t * testing.T ) {
3737 t .Parallel ()
3838
39- mock := new (MockT )
39+ mock := new (mockT )
4040 mockRequire := target .New (mock )
4141
4242 expected := `
7474func TestRequireYAMLEqWrapper_Array (t * testing.T ) {
7575 t .Parallel ()
7676
77- mock := new (MockT )
77+ mock := new (mockT )
7878 mockRequire := target .New (mock )
7979
8080 mockRequire .YAMLEq (`["foo", {"hello": "world", "nested": "hash"}]` , `["foo", {"nested": "hash", "hello": "world"}]` )
@@ -86,7 +86,7 @@ func TestRequireYAMLEqWrapper_Array(t *testing.T) {
8686func TestRequireYAMLEqWrapper_HashAndArrayNotEquivalent (t * testing.T ) {
8787 t .Parallel ()
8888
89- mock := new (MockT )
89+ mock := new (mockT )
9090 mockRequire := target .New (mock )
9191
9292 mockRequire .YAMLEq (`["foo", {"hello": "world", "nested": "hash"}]` , `{"foo": "bar", {"nested": "hash", "hello": "world"}}` )
@@ -98,7 +98,7 @@ func TestRequireYAMLEqWrapper_HashAndArrayNotEquivalent(t *testing.T) {
9898func TestRequireYAMLEqWrapper_HashesNotEquivalent (t * testing.T ) {
9999 t .Parallel ()
100100
101- mock := new (MockT )
101+ mock := new (mockT )
102102 mockRequire := target .New (mock )
103103
104104 mockRequire .YAMLEq (`{"foo": "bar"}` , `{"foo": "bar", "hello": "world"}` )
@@ -110,7 +110,7 @@ func TestRequireYAMLEqWrapper_HashesNotEquivalent(t *testing.T) {
110110func TestRequireYAMLEqWrapper_ActualIsSimpleString (t * testing.T ) {
111111 t .Parallel ()
112112
113- mock := new (MockT )
113+ mock := new (mockT )
114114 mockRequire := target .New (mock )
115115
116116 mockRequire .YAMLEq (`{"foo": "bar"}` , "Simple String" )
@@ -122,7 +122,7 @@ func TestRequireYAMLEqWrapper_ActualIsSimpleString(t *testing.T) {
122122func TestRequireYAMLEqWrapper_ExpectedIsSimpleString (t * testing.T ) {
123123 t .Parallel ()
124124
125- mock := new (MockT )
125+ mock := new (mockT )
126126 mockRequire := target .New (mock )
127127
128128 mockRequire .YAMLEq ("Simple String" , `{"foo": "bar", "hello": "world"}` )
@@ -134,7 +134,7 @@ func TestRequireYAMLEqWrapper_ExpectedIsSimpleString(t *testing.T) {
134134func TestRequireYAMLEqWrapper_ExpectedAndActualSimpleString (t * testing.T ) {
135135 t .Parallel ()
136136
137- mock := new (MockT )
137+ mock := new (mockT )
138138 mockRequire := target .New (mock )
139139
140140 mockRequire .YAMLEq ("Simple String" , "Simple String" )
@@ -146,11 +146,95 @@ func TestRequireYAMLEqWrapper_ExpectedAndActualSimpleString(t *testing.T) {
146146func TestRequireYAMLEqWrapper_ArraysOfDifferentOrder (t * testing.T ) {
147147 t .Parallel ()
148148
149- mock := new (MockT )
149+ mock := new (mockT )
150150 mockRequire := target .New (mock )
151151
152152 mockRequire .YAMLEq (`["foo", {"hello": "world", "nested": "hash"}]` , `[{ "hello": "world", "nested": "hash"}, "foo"]` )
153153 if ! mock .Failed {
154154 t .Error ("Check should fail" )
155155 }
156156}
157+
158+ func TestRequireYAMLEqBytesWrapper (t * testing.T ) {
159+ t .Parallel ()
160+
161+ t .Run ("should pass" , func (t * testing.T ) {
162+ t .Parallel ()
163+
164+ mock := new (mockT )
165+ mockRequire := target .New (mock )
166+
167+ mockRequire .YAMLEqBytes ([]byte (expectedYAML ), []byte (actualYAML ))
168+ if mock .Failed {
169+ t .Error ("Check should pass" )
170+ }
171+ })
172+
173+ t .Run ("should fail" , func (t * testing.T ) {
174+ t .Parallel ()
175+
176+ mock := new (mockT )
177+ mockRequire := target .New (mock )
178+
179+ mockRequire .YAMLEqBytes ([]byte (`{"foo": "bar"}` ), []byte (`{"foo": "bar", "hello": "world"}` ))
180+ if ! mock .Failed {
181+ t .Error ("Check should fail" )
182+ }
183+ })
184+ }
185+
186+ func TestRequireYAMLEqfWrapper (t * testing.T ) {
187+ t .Parallel ()
188+
189+ t .Run ("should pass" , func (t * testing.T ) {
190+ t .Parallel ()
191+
192+ mock := new (mockT )
193+ mockRequire := target .New (mock )
194+
195+ mockRequire .YAMLEqf (`{"hello": "world", "foo": "bar"}` , `{"foo": "bar", "hello": "world"}` , yamlCheckMsg , "equivalent" )
196+ if mock .Failed {
197+ t .Error ("Check should pass" )
198+ }
199+ })
200+
201+ t .Run ("should fail" , func (t * testing.T ) {
202+ t .Parallel ()
203+
204+ mock := new (mockT )
205+ mockRequire := target .New (mock )
206+
207+ mockRequire .YAMLEqf (`{"foo": "bar"}` , `{"foo": "bar", "hello": "world"}` , yamlCheckMsg , "not equivalent" )
208+ if ! mock .Failed {
209+ t .Error ("Check should fail" )
210+ }
211+ })
212+ }
213+
214+ func TestRequireYAMLEqBytesfWrapper (t * testing.T ) {
215+ t .Parallel ()
216+
217+ t .Run ("should pass" , func (t * testing.T ) {
218+ t .Parallel ()
219+
220+ mock := new (mockT )
221+ mockRequire := target .New (mock )
222+
223+ mockRequire .YAMLEqBytesf ([]byte (expectedYAML ), []byte (actualYAML ), yamlCheckMsg , "equivalent bytes" )
224+ if mock .Failed {
225+ t .Error ("Check should pass" )
226+ }
227+ })
228+
229+ t .Run ("should fail" , func (t * testing.T ) {
230+ t .Parallel ()
231+
232+ mock := new (mockT )
233+ mockRequire := target .New (mock )
234+
235+ mockRequire .YAMLEqBytesf ([]byte (`{"foo": "bar"}` ), []byte (`{"foo": "bar", "hello": "world"}` ), yamlCheckMsg , "not equivalent bytes" )
236+ if ! mock .Failed {
237+ t .Error ("Check should fail" )
238+ }
239+ })
240+ }
0 commit comments