Skip to content

Commit

Permalink
deserialization negative tests
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Fossati <thomas.fossati@linaro.org>
  • Loading branch information
thomas-fossati committed Dec 20, 2023
1 parent 13d3df5 commit 17df5a1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,19 @@ func Test_Collection_JSON_Serialize_ok(t *testing.T) {

assert.JSONEq(t, string(expected), string(actual))
}

func Test_Collection_JSON_Deserialize_fail_outer(t *testing.T) {
tv := []byte(`;rubbish json;`)

var actual JSONCollection
err := actual.Deserialize(tv)
assert.EqualError(t, err, `unmarshaling JSON collection: invalid character ';' looking for beginning of value`)
}

func Test_Collection_JSON_Deserialize_fail_inner(t *testing.T) {
tv := []byte(`{ "a": {} }`)

var actual JSONCollection
err := actual.Deserialize(tv)
assert.EqualError(t, err, `unmarshaling JSON collection item a: json: cannot unmarshal object into Go value of type []json.RawMessage`)
}

0 comments on commit 17df5a1

Please sign in to comment.