Update unit test's result messages#1812
Update unit test's result messages#1812Ekrekr merged 2 commits intodataform-co:mainfrom spider-man-tm:update-unit-test
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
cli/api/commands/test.ts
Outdated
| // Check if exactly one of the expected or actual values is null (XOR condition) | ||
| if ((expectedValue === null) !== (actualValue === null)) { | ||
| const expectedText = expectedValue === null ? 'null' : `"${expectedValue}"`; | ||
| const actualText = actualValue === null ? 'null' : `"${actualValue}"`; | ||
| rowMessages.push( | ||
| `For row ${i} and column "${column}": expected ${expectedText}, but saw ${actualText}.` | ||
| ); | ||
| break; | ||
| } |
There was a problem hiding this comment.
I much preferred your suggestion of
// Null value check
if (expectedValue === null && actualValue !== null) {
rowMessages.push(
`For row ${i} and column "${column}": expected null, but saw "${actualValue}".`
);
break;
}
if (expectedValue !== null && actualValue === null) {
rowMessages.push(
`For row ${i} and column "${column}": expected "${expectedValue}", but saw null.`
);
break;
}This is much clearer to follow the logic of!
There was a problem hiding this comment.
You're right, I also think that keeping it simple makes it easier to understand. I've committed.
d40e265
There was a problem hiding this comment.
@Ekrekr
Is there a plan to merge this PR?
|
I've run the tests, and all pass. Will merge, thanks for doing this! |
This PR is linked to the following issue:
close #1791
Current
Prepare the following table and its corresponding unit test.
Test table:
config { type: "table", schema: "hoge", name: "fuga" } select user_id from ${ref("users")}Test code:
config { type: "test", dataset: "fuga", } select 1 as user_id union all select cast(null as int64) as user_id input "users" { select 1 as user_id union all select 2 as user_id }Given that the expected block includes cast(null as int64), it would be more user-friendly to have the output display as follows:
However, the current output is as follows, which can cause confusion for the user:
Before Committing