Skip to content

Commit 8055bae

Browse files
committed
stores/yaml: use assert in tests
Signed-off-by: Martin Holst Swende <martin@swende.se>
1 parent 8c0ddad commit 8055bae

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

stores/yaml/store_test.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func TestComment7(t *testing.T) {
284284
func 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

309305
func 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

Comments
 (0)