diff --git a/collection_test.go b/collection_test.go index 9b9d635..e7fd8e5 100644 --- a/collection_test.go +++ b/collection_test.go @@ -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`) +}