Skip to content

Commit 3629f22

Browse files
committed
test(cubesql): Format JSON part of TestConnectionTransport SQL output
1 parent 311acc4 commit 3629f22

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

rust/cubesql/cubesql/src/compile/mod.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7278,13 +7278,15 @@ ORDER BY
72787278
.sql
72797279
.contains("ungrouped"));
72807280

7281-
assert!(query_plan
7282-
.as_logical_plan()
7283-
.find_cube_scan_wrapper()
7284-
.wrapped_sql
7285-
.unwrap()
7286-
.sql
7287-
.contains("[\"dim2\",\"asc\"]"));
7281+
let re = Regex::new(r#"\[[[:space:]]*"dim2",[[:space:]]*"asc"[[:space:]]*\]"#).unwrap();
7282+
assert!(re.is_match(
7283+
&query_plan
7284+
.as_logical_plan()
7285+
.find_cube_scan_wrapper()
7286+
.wrapped_sql
7287+
.unwrap()
7288+
.sql
7289+
));
72887290
}
72897291

72907292
#[tokio::test]
@@ -13732,7 +13734,7 @@ ORDER BY "source"."str0" ASC
1373213734
if Rewriter::top_down_extractor_enabled() {
1373313735
assert!(sql.contains("LIMIT 1000"));
1373413736
} else {
13735-
assert!(sql.contains("\"limit\":1000"));
13737+
assert!(sql.contains("\"limit\": 1000"));
1373613738
}
1373713739
assert!(sql.contains("% 7"));
1373813740

rust/cubesql/cubesql/src/compile/test/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,10 @@ impl TransportService for TestConnectionTransport {
795795
});
796796
Ok(SqlResponse {
797797
sql: SqlQuery::new(
798-
format!("SELECT * FROM {}", serde_json::to_string(&inputs).unwrap()),
798+
format!(
799+
"SELECT * FROM {}",
800+
serde_json::to_string_pretty(&inputs).unwrap()
801+
),
799802
expression_params.unwrap_or(Vec::new()),
800803
),
801804
})

rust/cubesql/cubesql/src/compile/test/test_user_change.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,6 @@ GROUP BY 1
271271
let sql_query = load_calls[0].sql_query.as_ref().unwrap();
272272
// This should be placed from load meta to query by TestConnectionTransport::sql
273273
// It would mean that SQL generation used changed user
274-
assert!(sql_query.sql.contains(r#""changeUser":"gopher""#));
274+
assert!(sql_query.sql.contains(r#""changeUser": "gopher""#));
275275
assert_eq!(load_calls[0].meta.change_user(), Some("gopher".to_string()));
276276
}

rust/cubesql/cubesql/src/compile/test/test_wrapper.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ async fn test_simple_subquery_wrapper_projection() {
426426
.wrapped_sql
427427
.unwrap()
428428
.sql
429-
.contains("\\\\\\\"limit\\\\\\\":1"));
429+
.contains("\\\\\\\"limit\\\\\\\": 1"));
430430

431431
let _physical_plan = query_plan.as_physical_plan().await.unwrap();
432432
}
@@ -482,7 +482,7 @@ async fn test_simple_subquery_wrapper_filter_equal() {
482482
.wrapped_sql
483483
.unwrap()
484484
.sql
485-
.contains("\\\\\\\"limit\\\\\\\":1"));
485+
.contains("\\\\\\\"limit\\\\\\\": 1"));
486486

487487
let _physical_plan = query_plan.as_physical_plan().await.unwrap();
488488
}

0 commit comments

Comments
 (0)