Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

[Bug] Api Unit test do not compile

Open Arthur-Milchior opened this issue 2 years ago • 0 comments

The main problem is that API's unit test seems not to be tested by our CI. No idea how to fix that. But it probably should have been detected sooner.

The more local problem is that the test splitFieldsShouldReturnNullWhenStringIsNull was broken in 9024e6629b3f3a02e33c94c95c2f0e9e7d819322 . It's not clear how to repair it. The function splitFields do not accept null anymore. The question is whether the good correction is:

  • we should accept null again
  • we should remove the test

I don't understand why we actually tested that. By any luck, @rodrigobressan, you would not recall why you added it in e2d4f48cae6dd6aa8898d771d7d2e0e94737d865 , five years ago? (By the way, nice to meet you, I don't think we ever interacted. ) Was it just for the sake of completeness because you did not used @NonNull annotation at the time, or was there a reason to really expect a null input?

Personally, I'm not confident enough with API to know whether we can expect some null values from cursor. I believe that this can't occur because fields are never passed as argument from the API call, but always as result. But I may be wrong here. I believe that anyway, we should not accept "null" fields as input, but I even less want to break our APIs without good reason

I also ping @n1snt because this is blocking your PR #11416, and also because the nullability issue should have been noted when merging your commit 9024e6629b3f3a02e33c94c95c2f0e9e7d819322, so I assume you want to be involved. (And for the sake of clarity, this is absolutely not to blame you in any way whatshowever. This passed CI test and code review, so even if this commit broke some build, I consider it to be a good as all the other conversion commit)

Arthur-Milchior avatar Jul 24 '22 18:07 Arthur-Milchior