Skip to content

Commit 8b24303

Browse files
test: Integration test failures easier to understand (#2604)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a7e8593 commit 8b24303

26 files changed

+34
-38
lines changed

bacon.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ a = "job:check-all"
5353
c = "job:clippy"
5454
d = "job:doc-open"
5555
f = "job:test-fast"
56-
# `g` for standard carGo tests
56+
# `g` for standard cargo tests
5757
g = "job:test-cargo"
5858
r = "job:run"
5959
t = "job:test"

prql-compiler/tests/integration/main.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ fn compile(prql: &str) -> Result<String, prql_compiler::ErrorMessages> {
3636
fn test_sql_examples() {
3737
glob!("queries/**/*.prql", |path| {
3838
let sql = fs::read_to_string(path).unwrap();
39-
assert_snapshot!(
40-
path.file_name().unwrap().to_string_lossy().to_string(),
41-
compile(&sql).unwrap(),
42-
&sql
43-
)
39+
assert_snapshot!("sql", compile(&sql).unwrap(), &sql)
4440
});
4541
}
4642

@@ -56,7 +52,7 @@ fn test_rdbms() {
5652
// for each of the queries
5753
glob!("queries/**/*.prql", |path| {
5854
let test_name = path
59-
.file_name()
55+
.file_stem()
6056
.and_then(|s| s.to_str())
6157
.unwrap_or_default();
6258

@@ -98,7 +94,7 @@ fn test_rdbms() {
9894
for row in first_result.1 {
9995
writeln!(&mut result_string, "{}", row.join(",")).unwrap_or_default();
10096
}
101-
assert_snapshot!(result_string);
97+
assert_snapshot!("results", result_string, &prql);
10298
});
10399
}
104100

prql-compiler/tests/integration/snapshots/[email protected]

-12
This file was deleted.

prql-compiler/tests/integration/snapshots/integration__rdbms@set_ops_remove.prql.snap

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "from tracks\nsort [-bytes]\nselect [\n name,\n bin = ((album_id | as REAL) * 99)\n]\ntake 20\n"
44
input_file: prql-compiler/tests/integration/queries/cast.prql
55
---
66
Through a Looking Glass,22671
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "from tracks\nselect [album_id, genre_id]\ngroup tracks.* (take 1)\nsort tracks.*\n"
44
input_file: prql-compiler/tests/integration/queries/distinct.prql
55
---
66
1,1

prql-compiler/tests/integration/snapshots/integration__rdbms@genre_counts.prql.snap renamed to prql-compiler/tests/integration/snapshots/integration__results@genre_counts.prql.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "let genre_count = (\n from genres\n aggregate a = count\n)\n\nfrom genre_count\nfilter a > 0\nselect a = -a\n"
44
input_file: prql-compiler/tests/integration/queries/genre_counts.prql
55
---
66
-25

prql-compiler/tests/integration/snapshots/integration__rdbms@group_all.prql.snap renamed to prql-compiler/tests/integration/snapshots/integration__results@group_all.prql.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "from a=albums\ntake 10\njoin tracks [==album_id]\ngroup [a.album_id, a.title] (aggregate price = ((sum tracks.unit_price)))\nsort album_id\n"
44
input_file: prql-compiler/tests/integration/queries/group_all.prql
55
---
66
1,For Those About To Rock We Salute You,9.9

prql-compiler/tests/integration/snapshots/integration__rdbms@group_sort.prql.snap renamed to prql-compiler/tests/integration/snapshots/integration__results@group_sort.prql.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "from tracks\nderive d = album_id + 1\ngroup d (\n aggregate [\n n1 = (track_id | sum),\n ]\n)\nsort d\ntake 10\nselect [ d1 = d, n1 ]\n"
44
input_file: prql-compiler/tests/integration/queries/group_sort.prql
55
---
66
2,91

prql-compiler/tests/integration/snapshots/integration__rdbms@invoice_totals.prql.snap renamed to prql-compiler/tests/integration/snapshots/integration__results@invoice_totals.prql.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "# skip_mssql (error: The function 'LAG' may not have a window frame.)\nfrom i=invoices\njoin ii=invoice_items [==invoice_id]\nderive [\n city = i.billing_city,\n street = i.billing_address,\n]\ngroup [city, street] (\n aggregate [\n num_orders = s\"COUNT(DISTINCT {i.invoice_id})\",\n num_tracks = sum ii.quantity,\n total_price = sum (ii.unit_price * ii.quantity),\n ]\n)\ngroup [city] (\n sort street\n window expanding:true (\n derive [running_total_num_tracks = sum num_tracks]\n )\n)\nsort city\nderive [num_tracks_last_week = lag 7 num_tracks]\nselect [\n city,\n street,\n num_orders,\n num_tracks,\n running_total_num_tracks,\n num_tracks_last_week\n]\ntake 20\n"
44
input_file: prql-compiler/tests/integration/queries/invoice_totals.prql
55
---
66
Amsterdam,Lijnbaansgracht 120bg,7,38,38,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
source: prql-compiler/tests/integration/main.rs
3+
expression: "# skip_mssql (the keyword RECURSIVE is not allowed and you have to declare the columns for CTE)\nfrom_text format:json '[{\"n\": 1 }]'\nselect n = n - 2\nloop (\n filter n<4\n select n = n+1\n)\nselect n = n * 2\n"
4+
input_file: prql-compiler/tests/integration/queries/loop.prql
5+
---
6+
-2
7+
0
8+
2
9+
4
10+
6
11+
8
12+
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "# skip_mssql (https://github.com/PRQL/prql/issues/2448)\n# skip_mysql (regex not yet implemented)\n# skip_sqlite (regex not yet implemented)\n# booleans cannot be selected directly. instead CASE is needed (https://dba.stackexchange.com/a/2774)\nfrom tracks\n\nfilter (name ~= \"Love\")\nfilter ((milliseconds / 1000 / 60) | in 3..4)\nsort track_id\ntake 1..15\nselect [name, composer]\n"
44
input_file: prql-compiler/tests/integration/queries/pipelines.prql
55
---
66
My Love,Jauperi/Zeu Góes
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
source: prql-compiler/tests/integration/main.rs
3+
expression: "let distinct = rel -> (from t = _param.rel | group [t.*] (take 1))\n\nfrom_text format:json '{ \"columns\": [\"a\"], \"data\": [[1], [2], [2], [3]] }'\ndistinct\nremove (from_text format:json '{ \"columns\": [\"a\"], \"data\": [[1], [2]] }')\n"
4+
input_file: prql-compiler/tests/integration/queries/set_ops_remove.prql
5+
---
6+
3
7+
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "from e=employees\nfilter first_name != \"Mitchell\"\nsort [first_name, last_name]\n\n# joining may use HashMerge, which can undo ORDER BY\njoin manager=employees side:left [e.reports_to == manager.employee_id]\n\nselect [e.first_name, e.last_name, manager.first_name]\n"
44
input_file: prql-compiler/tests/integration/queries/sort.prql
55
---
66
Andrew,Adams,Michael
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "from tracks\nsort milliseconds\nselect display = case [\n composer != null => composer,\n genre_id < 17 => 'no composer',\n true => f'unknown composer'\n]\ntake 10\n"
44
input_file: prql-compiler/tests/integration/queries/switch.prql
55
---
66
Samuel Rosa
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: "# skip_mssql\nlet distinct = rel -> (from t = _param.rel | group [t.*] (take 1))\n\nfrom_text format:json '{ \"columns\": [\"a\"], \"data\": [[1], [2], [2], [3]] }'\ndistinct\nremove (from_text format:json '{ \"columns\": [\"a\"], \"data\": [[1], [2]] }')\n"
3+
expression: "let distinct = rel -> (from t = _param.rel | group [t.*] (take 1))\n\nfrom_text format:json '{ \"columns\": [\"a\"], \"data\": [[1], [2], [2], [3]] }'\ndistinct\nremove (from_text format:json '{ \"columns\": [\"a\"], \"data\": [[1], [2]] }')\n"
44
input_file: prql-compiler/tests/integration/queries/set_ops_remove.prql
55
---
66
WITH table_4 AS (
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: "from e=employees\nfilter first_name != \"Mitchell\"\nsort [first_name, last_name]\n\n# joining may use HashMerge, which can undo ORDER BY\njoin manager=employees side:left [e.reports_to == manager.employee_id]\n\nselect [e.first_name, e.last_name, manager.first_name]"
3+
expression: "from e=employees\nfilter first_name != \"Mitchell\"\nsort [first_name, last_name]\n\n# joining may use HashMerge, which can undo ORDER BY\njoin manager=employees side:left [e.reports_to == manager.employee_id]\n\nselect [e.first_name, e.last_name, manager.first_name]\n"
44
input_file: prql-compiler/tests/integration/queries/sort.prql
55
---
66
WITH table_1 AS (

0 commit comments

Comments
 (0)