-
Notifications
You must be signed in to change notification settings - Fork 218
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
test: Refactor integration tests #2362
Conversation
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.
Awesome, thanks a lot @Jelenkee — this is shaping up to be really excellent code. I left a few comments. Happy to merge now and do those changes in another PR — as you wish.
"{} == {}: {test_name}", | ||
first_result.0, | ||
k | ||
); | ||
} |
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.
Your implementation is probably better at debugging, so feel completely free to keep it.
That said, I think it's possible to simplify it a bit — here's one approach. The result is basically the same (the only difference is that the snapshot file contains the input prql as the expression, because of the third item passed to assert_snapshot!
)
#[test]
fn test_rdbms() {
let runtime = Runtime::new().unwrap();
let mut connections = get_connections(&runtime);
for con in &mut connections {
setup_connection(con.as_mut(), &runtime);
}
// for each of the queries
glob!("queries/**/*.prql", |path| {
// read
let prql = fs::read_to_string(path).unwrap();
if prql.contains("skip_test") {
return;
}
for con in &mut connections {
let vendor = con.get_dialect().to_string().to_lowercase();
if prql.contains(format!("skip_{}", vendor).as_str()) {
continue;
}
let result = run_query(con.as_mut(), prql.as_str(), &runtime);
let result_string = result.iter().map(|row| row.join(",")).join("\n");
assert_snapshot!("rdbms".to_string(), &result_string, &prql);
}
});
}
(hopefully this is helpful feedback, rather than dispiriting that someone is "rewriting your code", let me know either way)
expression: result_string | ||
input_file: prql-compiler/tests/integration/queries/invoice_totals.prql | ||
--- | ||
2009-01,2009-01-01,1,2,1.98,2, |
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.
Not on you at all, and def not necessary in this PR, but one thing we could do is adjust the queries so they produce more aggregated results — we probably get the same test coverage with more legible outputs...
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.
Sure.
And we have to remove the skips for certain dbs. Especially MsSQL is hardly tested.
Co-authored-by: Maximilian Roos <5635139+max-sixty@users.noreply.github.com>
Looking great! We can merge whenever you're ready! |
@max-sixty Docs have been added. You may have a look at it. If everything is fine, you can merge |
for more information, see https://pre-commit.ci
Co-authored-by: eitsupi <50911393+eitsupi@users.noreply.github.com>
Great — am promoting it from Draft and will merge! |
Thanks @Jelenkee ! Is there anything else remaining on the infra? I think it's in a very good state. If you thought #2362 (comment) was valid, fine to make that change. We could also start thinking about the current exclusions — was there anything you saw that's a PRQL bug (more than just the DB doesn't support it — in which case maybe we could improve the error messages but can't make it work...)? |
#2353