-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Update tests to use insta / make them easier to update #17945
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
Changes from 1 commit
cf0a4a5
5868177
c202779
205ca16
d7b94c1
2d2f87f
9b1dbeb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2486,7 +2486,7 @@ mod tests { | |
// the cast here is implicit so has CastOptions with safe=true | ||
let expected = r#"BinaryExpr { left: Column { name: "c7", index: 2 }, op: Lt, right: Literal { value: Int64(5), field: Field { name: "lit", data_type: Int64, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} } }, fail_on_overflow: false }"#; | ||
|
||
assert!(format!("{exec_plan:?}").contains(expected)); | ||
assert_contains!(format!("{exec_plan:?}"), expected); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. likewise this makes it easier to update the test as now the actual output is also printed |
||
Ok(()) | ||
} | ||
|
||
|
@@ -2510,9 +2510,7 @@ mod tests { | |
&session_state, | ||
); | ||
|
||
let expected = r#"Ok(PhysicalGroupBy { expr: [(Column { name: "c1", index: 0 }, "c1"), (Column { name: "c2", index: 1 }, "c2"), (Column { name: "c3", index: 2 }, "c3")], null_expr: [(Literal { value: Utf8(NULL), field: Field { name: "lit", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c1"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c2"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c3")], groups: [[false, false, false], [true, false, false], [false, true, false], [false, false, true], [true, true, false], [true, false, true], [false, true, true], [true, true, true]] })"#; | ||
|
||
assert_eq!(format!("{cube:?}"), expected); | ||
insta::assert_snapshot!(format!("{cube:?}"), @r#"Ok(PhysicalGroupBy { expr: [(Column { name: "c1", index: 0 }, "c1"), (Column { name: "c2", index: 1 }, "c2"), (Column { name: "c3", index: 2 }, "c3")], null_expr: [(Literal { value: Utf8(NULL), field: Field { name: "lit", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c1"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c2"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c3")], groups: [[false, false, false], [true, false, false], [false, true, false], [false, false, true], [true, true, false], [true, false, true], [false, true, true], [true, true, true]] })"#); | ||
|
||
|
||
Ok(()) | ||
} | ||
|
@@ -2537,9 +2535,7 @@ mod tests { | |
&session_state, | ||
); | ||
|
||
let expected = r#"Ok(PhysicalGroupBy { expr: [(Column { name: "c1", index: 0 }, "c1"), (Column { name: "c2", index: 1 }, "c2"), (Column { name: "c3", index: 2 }, "c3")], null_expr: [(Literal { value: Utf8(NULL), field: Field { name: "lit", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c1"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c2"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c3")], groups: [[true, true, true], [false, true, true], [false, false, true], [false, false, false]] })"#; | ||
|
||
assert_eq!(format!("{rollup:?}"), expected); | ||
insta::assert_snapshot!(format!("{rollup:?}"), @r#"Ok(PhysicalGroupBy { expr: [(Column { name: "c1", index: 0 }, "c1"), (Column { name: "c2", index: 1 }, "c2"), (Column { name: "c3", index: 2 }, "c3")], null_expr: [(Literal { value: Utf8(NULL), field: Field { name: "lit", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c1"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c2"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c3")], groups: [[true, true, true], [false, true, true], [false, false, true], [false, false, false]] })"#); | ||
|
||
Ok(()) | ||
} | ||
|
@@ -2677,35 +2673,13 @@ mod tests { | |
let logical_plan = LogicalPlan::Extension(Extension { | ||
node: Arc::new(NoOpExtensionNode::default()), | ||
}); | ||
let plan = planner | ||
let e = planner | ||
.create_physical_plan(&logical_plan, &session_state) | ||
.await; | ||
.await | ||
.expect_err("planning error") | ||
.strip_backtrace(); | ||
|
||
let expected_error: &str = "Error during planning: \ | ||
Extension planner for NoOp created an ExecutionPlan with mismatched schema. \ | ||
LogicalPlan schema: \ | ||
DFSchema { inner: Schema { fields: \ | ||
[Field { name: \"a\", \ | ||
data_type: Int32, \ | ||
nullable: false, \ | ||
dict_id: 0, \ | ||
dict_is_ordered: false, metadata: {} }], \ | ||
metadata: {} }, field_qualifiers: [None], \ | ||
functional_dependencies: FunctionalDependencies { deps: [] } }, \ | ||
ExecutionPlan schema: Schema { fields: \ | ||
[Field { name: \"b\", \ | ||
data_type: Int32, \ | ||
nullable: false, \ | ||
dict_id: 0, \ | ||
dict_is_ordered: false, metadata: {} }], \ | ||
metadata: {} }"; | ||
match plan { | ||
Ok(_) => panic!("Expected planning failure"), | ||
Err(e) => assert!( | ||
e.to_string().contains(expected_error), | ||
"Error '{e}' did not contain expected error '{expected_error}'" | ||
), | ||
} | ||
insta::assert_snapshot!(e, @r#"Error during planning: Extension planner for NoOp created an ExecutionPlan with mismatched schema. LogicalPlan schema: DFSchema { inner: Schema { fields: [Field { name: "a", data_type: Int32, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }], metadata: {} }, field_qualifiers: [None], functional_dependencies: FunctionalDependencies { deps: [] } }, ExecutionPlan schema: Schema { fields: [Field { name: "b", data_type: Int32, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }], metadata: {} }"#); | ||
} | ||
|
||
#[tokio::test] | ||
|
@@ -2723,8 +2697,7 @@ mod tests { | |
|
||
let expected = "expr: [ProjectionExpr { expr: BinaryExpr { left: BinaryExpr { left: Column { name: \"c1\", index: 0 }, op: Eq, right: Literal { value: Utf8(\"a\"), field: Field { name: \"lit\", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} } }, fail_on_overflow: false }, op: Or, right: BinaryExpr { left: Column { name: \"c1\", index: 0 }, op: Eq, right: Literal { value: Utf8(\"1\"), field: Field { name: \"lit\", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} } }, fail_on_overflow: false }, fail_on_overflow: false }"; | ||
|
||
let actual = format!("{execution_plan:?}"); | ||
assert!(actual.contains(expected), "{}", actual); | ||
assert_contains!(format!("{execution_plan:?}"), expected); | ||
|
||
Ok(()) | ||
} | ||
|
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.
by changing this to
assert_snapshot
it is easier to update in the arrow-57 upgrade, where this message changes