-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Migrate user_defined tests to insta #15255
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
Conversation
cc @blaginin |
Thanks @shruti2522 ! |
Hey! I’m a bit worried that now to understand the test you’ll need to look into two places: open the test file and also search for the snapshot file… that’s why in the example pr (#15165) I used inline snapshots. do you think we should use the same approach here? |
Hey @blaginin, you are right about this, at first I tried implementing the inline snapshots only, but I ran into errors while running tests for |
Can you please explain more on this? I tried modifying async ![]()
Just to give a bit of context, we had a discussion about inline / file snapshots here: #13672 (comment) and #13672 (comment). To me personally, it feels like we can use snapshot files, but the snapshot itself should give enough information to understand the context. For example, in CLI, you can see program input and tests, and the snapshot file itself doesn't contain a lot of logic. Here I'm not sure if that's the case for ALL the test fixtures? Maybe some of them can be inline? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @blaginin and @shruti2522
I do think that inline snapshots would be better (and more consistent with the rest of the code). Can you please update the PR as suggested by @blaginin and mark the PR ready for review when done?
Thanks again for this (and all the other recent PRs)
Yes, it worked. I was using insta::allow_duplicates!(|| {
insta::with_settings!({
description => description,
}, {
insta::assert_snapshot!(actual, @r###"
+-------------+---------+
| customer_id | revenue |
+-------------+---------+
| paul | 300 |
| jorge | 200 |
| andy | 150 |
+-------------+---------+
"###);
});
})(); On changing it to this it worked insta::allow_duplicates! {
insta::with_settings!({
description => description,
}, {
insta::assert_snapshot!(actual, @r###"
+-------------+---------+
| customer_id | revenue |
+-------------+---------+
| paul | 300 |
| jorge | 200 |
| andy | 150 |
+-------------+---------+
"###);
});
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @shruti2522 and @blaginin -- thi slooks great to me!
fn fmt_batches(batches: &[RecordBatch]) -> String { | ||
use arrow::util::pretty::pretty_format_batches; | ||
match pretty_format_batches(batches) { | ||
Ok(formatted) => formatted.to_string(), | ||
Err(e) => format!("Error formatting record batches: {}", e), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use batches_to_string
for that?
fn fmt_batches(batches: &[RecordBatch]) -> String { | ||
use arrow::util::pretty::pretty_format_batches; | ||
match pretty_format_batches(batches) { | ||
Ok(formatted) => formatted.to_string(), | ||
Err(e) => format!("Error formatting record batches: {}", e), | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this can be removed as well
fn fmt_batches(batches: &[RecordBatch]) -> String { | ||
use arrow::util::pretty::pretty_format_batches; | ||
match pretty_format_batches(batches) { | ||
Ok(formatted) => formatted.to_string(), | ||
Err(e) => format!("Error formatting record batches: {}", e), | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good call -- I took the liberty of pushing a commit to make the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!!
Thanks @shruti2522 and @blaginin 🙏 |
Which issue does this PR close?
insta
#15247 .Rationale for this change
What changes are included in this PR?
migrate tests in
datafusion/core/tests/user_defined
to instaAre these changes tested?
Are there any user-facing changes?