@@ -284,7 +284,7 @@ func TestComment7(t *testing.T) {
284284func TestDuplicateAttributes (t * testing.T ) {
285285 // Duplicate keys are _not_ valid yaml.
286286 //
287- // See https://yaml.org/spec/1.2.2/
287+ // See https://yaml.org/spec/1.2.2/#mapping
288288 // > The content of a mapping node is an unordered set of key/value node pairs,
289289 // > with the restriction that each of the keys is unique.
290290 //
@@ -297,13 +297,9 @@ rootunique:
297297`
298298 s := new (Store )
299299 _ , err := s .LoadPlainFile ([]byte (data ))
300- if err == nil {
301- t .Errorf ("Expected error" )
302- }
303- if have , want := err .Error (), `yaml: unmarshal errors:
304- line 3: mapping key "hello" already defined at line 2` ; have != want {
305- t .Errorf ("have '%v', want '%v'" , have , want )
306- }
300+ assert .NotNil (t , err )
301+ assert .Equal (t , `yaml: unmarshal errors:
302+ line 3: mapping key "hello" already defined at line 2` , err .Error ())
307303}
308304
309305func TestReservedAttributes (t * testing.T ) {
@@ -313,10 +309,6 @@ sops: The attribute 'sops' must be rejected, otherwise the file cannot be opened
313309`
314310 s := new (Store )
315311 _ , err := s .LoadPlainFile ([]byte (data ))
316- if err == nil {
317- t .Errorf ("Expected error" )
318- }
319- if have , want := err .Error (), `YAML doc used reserved word 'sops'` ; have != want {
320- t .Errorf ("have '%v', want '%v'" , have , want )
321- }
312+ assert .NotNil (t , err )
313+ assert .Equal (t , `YAML doc used reserved word 'sops'` , err .Error ())
322314}
0 commit comments