@@ -248,3 +248,70 @@ tests:
248248
249249 _ = ParseYAML (yaml )
250250}
251+
252+ func Test_YAMLConfig_MarshalYAML (t * testing.T ) {
253+ conf := YAMLConfig {Tests : map [string ]YAMLTest {
254+ "return_string" : {
255+ Stdout : runtime.ExpectedOut {Contains : []string {"stdout string" }},
256+ Stderr : runtime.ExpectedOut {Contains : []string {"stderr string" }},
257+ },
258+ "return_struct" : {
259+ Stdout : runtime.ExpectedOut {
260+ Contains : []string {"stdout" },
261+ LineCount : 10 ,
262+ },
263+ Stderr : runtime.ExpectedOut {
264+ Contains : []string {"stderr" },
265+ LineCount : 10 ,
266+ },
267+ },
268+ "return_nil" : {
269+ Stdout : runtime.ExpectedOut {},
270+ Stderr : runtime.ExpectedOut {},
271+ },
272+ }}
273+
274+ out , _ := conf .MarshalYAML ()
275+ r := out .(YAMLConfig )
276+
277+ assert .Equal (t , "stdout string" , r .Tests ["return_string" ].Stdout )
278+ assert .Equal (t , "stderr string" , r .Tests ["return_string" ].Stderr )
279+
280+ assert .Equal (t , conf .Tests ["return_struct" ].Stdout , r .Tests ["return_struct" ].Stdout )
281+ assert .Equal (t , conf .Tests ["return_struct" ].Stderr , r .Tests ["return_struct" ].Stderr )
282+
283+ assert .Nil (t , r .Tests ["return_nil" ].Stdout )
284+ assert .Nil (t , r .Tests ["return_nil" ].Stderr )
285+ }
286+
287+ func Test_convertExpectOut_ReturnNilIfEmpty (t * testing.T ) {
288+ out := runtime.ExpectedOut {
289+ Contains : []string {"" },
290+ }
291+
292+ r := convertExpectedOut (out )
293+
294+ assert .Nil (t , r )
295+ }
296+
297+ func Test_convertExpectedOut_ReturnContainsAsString (t * testing.T ) {
298+ out := runtime.ExpectedOut {
299+ Contains : []string {"test" },
300+ }
301+
302+ r := convertExpectedOut (out )
303+
304+ assert .Equal (t , "test" , r )
305+ }
306+
307+ func Test_convertExpectedOut_ReturnFullStruct (t * testing.T ) {
308+ out := runtime.ExpectedOut {
309+ Contains : []string {"hello" , "hi" },
310+ LineCount : 10 ,
311+ Exactly : "test" ,
312+ }
313+
314+ r := convertExpectedOut (out )
315+
316+ assert .Equal (t , out , r )
317+ }
0 commit comments