Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): Bump Truth to 1.4.2. #5194

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

cpovirk
Copy link

@cpovirk cpovirk commented Apr 1, 2024

This requires adapting to Truth's recent nullness annotations.

Specifically, a Subject constructor (and the associated
Subject.Factory and assertThat function) should accept a null actual
value. By doing so, it makes it possible to write
assertThat(foo).isNull(), for example.

This does not necessarily mean that all assertions will pass if the caller
passes null. Obviously isNotNull() will fail, of course, but so too may
other assertions, like hasFoundProducts will here.

(In principle, it would be nice for all assertions to fail with
detailed NullPointerException messages
. In practice, we mostly
haven't done that even for the core Truth assertions. So I haven't here,
either.)

Without this PR, the error that Truth 1.4.2 produces is:

ProductsAPITest.kt:245:46 Type mismatch: inferred type is KFunction2<FailureMetadata, Search, ProductsAPITest.SearchSubject> but (FailureMetadata!, TypeVariable(ActualT)?) -> TypeVariable(SubjectT)! was expected

Fixes #5191

This requires adapting to Truth's recent nullness annotations.

Specifically, a `Subject` constructor (and the associated
`Subject.Factory` and `assertThat` function) should accept a null actual
value. By doing so, it makes it possible to write
`assertThat(foo).isNull()`, for example.

This does not necessarily mean that all assertions will _pass_ if the caller
passes `null`. Obviously `isNotNull()` will fail, of course, but so too may
other assertions, like `hasFoundProducts` will here.

(In principle, it would be nice for all assertions to fail _with
detailed `NullPointerException` messages_. In practice, we mostly
haven't done that even for the core Truth assertions. So I haven't here,
either.)

Without this PR, the error that Truth 1.4.2 produces is:

```
ProductsAPITest.kt:245:46 Type mismatch: inferred type is KFunction2<FailureMetadata, Search, ProductsAPITest.SearchSubject> but (FailureMetadata!, TypeVariable(ActualT)?) -> TypeVariable(SubjectT)! was expected
```

Fixes openfoodfacts#5191
Copy link

sonarcloud bot commented Apr 1, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@cpovirk cpovirk changed the title Bump Truth to 1.4.2. build(deps): Bump Truth to 1.4.2. Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant