fix: retry a malformed answer once and log the text around the fault
This commit is contained in:
@@ -280,3 +280,14 @@ func TestScanRun(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestParsePackageMalformedAnswer(t *testing.T) {
|
||||
// What the first real scan hit: an object that closes early.
|
||||
_, err := parsePackage([]byte(`{"is_error":false,"result":"{\"company\":\"Adyen\"}, \"title\":\"Engineer\"}"}`))
|
||||
if !errors.Is(err, errBadAnswer) {
|
||||
t.Fatalf("err = %v, want errBadAnswer so the assessment is retried", err)
|
||||
}
|
||||
if !strings.Contains(err.Error(), `Adyen`) {
|
||||
t.Errorf("the error should quote the answer near the fault, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user