file: add JSON file which fails Validate() during FileFromJSON
@@ -854,14 +854,26 @@ func TestFile__readInvalidJson(t *testing.T) {
if err != nil {
t.Fatal(err)
}
+ if _, err := FileFromJSON(bs); err == nil {
+ t.Error("expected error")
+ } else {
+ if !strings.Contains(err.Error(), "problem reading File") {
+ t.Fatal(err)
+ }
+ }
- _, err = FileFromJSON(bs)
-
+ // a file which fails .Validate()
+ path = filepath.Join("test", "testdata", "ppd-invalid-EntryDetail-checkDigit.json")
+ bs, err = ioutil.ReadFile(path)
if err != nil {
- if strings.Contains(err.Error(), "problem reading File") {
- } else {
t.Fatal(err)
}
+ if _, err := FileFromJSON(bs); err == nil {
+ t.Error("expected error")
+ } else {
+ if !strings.Contains(err.Error(), "batch #1 (PPD) FieldError RDFIIdentification 1 does not match calculated check digit 4") {
+ t.Error(err)
+ }
}
}
