-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revamp failure testing with query assertions
Before the introduction of query assertions (the `QueryAssert` class), `assertQueryFails` was used to verify that a query fails with expected error message AND the failure exception type is `TrinoException`. With query assertions, the typical pattern for testing query failures became: assertThatThrownBy(() -> query(...)) .... This unfortunately does not verify that the exception type is the `TrinoException`. The existing alternative: assertTrinoExceptionThrownBy(() -> query(...)) ... is rarely used, perhaps because it's longer and the established shorter pattern is followed. Both above methods share the disadvantage of basing on the `QueryAssert` construction side-effect of evaluating the query eagerly. This commit revamps `QueryAssert` to make failures first class citizen from `QueryAssert` perspective, on par with query results. Expected failures are verified to be `TrinoException` type. The result is more fluent API, as both success and failures assertions are available on the same query assert object, and thus can be auto-completed by an IDE. From code updating perspective, most of the code updates fall into two categories: * failure testing. This functionality is available from query assert via `.failure()` accessor. Code was updated with regular expression - search for: `(assertThatThrownBy|assertTrinoExceptionThrownBy)\(\(\) -> (assertions\.)?query\(` - replace with: `assertThat($2query(` - add `.failure()` to access assertions on the failure exception. * detailed inspection of `MaterializedResult` objects. This lower-level functionality is available from query assert via `.result()` accessor.
- Loading branch information
Showing
81 changed files
with
1,220 additions
and
962 deletions.
There are no files selected for viewing
373 changes: 276 additions & 97 deletions
373
core/trino-main/src/test/java/io/trino/sql/query/QueryAssertions.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
209 changes: 104 additions & 105 deletions
209
core/trino-main/src/test/java/io/trino/sql/query/TestCheckConstraint.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.