Skip to content

Commit a94925c

Browse files
committed
test: port remaining unit-test selector cases and cover backslash dbt path selectors
1 parent 4d0a58f commit a94925c

4 files changed

Lines changed: 66 additions & 3 deletions

File tree

‎crates/sqlbuild-analysis/src/planner_selection/tests/test_planner_selection.rs‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,17 @@ fn given_order_selectors_when_splitting_unit_tests_then_tests_and_resources_sepa
251251
true,
252252
)),
253253
},
254+
UnitTestSplitTestCase {
255+
description: "a command that runs no unit tests rejects a bare test name",
256+
select: texts(&["order_status"]),
257+
exclude: Vec::new(),
258+
accepts_unit_tests: false,
259+
expected_split: Err(failure(
260+
"S013",
261+
"selector 'order_status' selects a unit test; only `sqb test` and `sqb build` accept unit-test selectors",
262+
None,
263+
)),
264+
},
254265
UnitTestSplitTestCase {
255266
description: "a command that runs no unit tests rejects test: selectors",
256267
select: texts(&["orders test:customer_status"]),
@@ -262,6 +273,17 @@ fn given_order_selectors_when_splitting_unit_tests_then_tests_and_resources_sepa
262273
None,
263274
)),
264275
},
276+
UnitTestSplitTestCase {
277+
description: "an unknown test: name suggests the nearest unit tests",
278+
select: texts(&["test:order_stats"]),
279+
exclude: Vec::new(),
280+
accepts_unit_tests: true,
281+
expected_split: Err(failure(
282+
"S007",
283+
"unknown unit test name 'order_stats'",
284+
Some("did you mean 'order_status'?"),
285+
)),
286+
},
265287
UnitTestSplitTestCase {
266288
description: "an unknown bare name suggests the closest unit test",
267289
select: texts(&["customer_stat"]),
@@ -273,6 +295,28 @@ fn given_order_selectors_when_splitting_unit_tests_then_tests_and_resources_sepa
273295
Some("did you mean 'customer_status'?"),
274296
)),
275297
},
298+
UnitTestSplitTestCase {
299+
description: "graph expansion of a unit test is refused",
300+
select: texts(&["+order_status"]),
301+
exclude: Vec::new(),
302+
accepts_unit_tests: true,
303+
expected_split: Err(failure(
304+
"S013",
305+
"selector '+order_status' expands a unit test with '+'; unit tests have no lineage, so select them by name without '+'",
306+
None,
307+
)),
308+
},
309+
UnitTestSplitTestCase {
310+
description: "intersecting a unit test is refused",
311+
select: texts(&["order_status,tag:daily"]),
312+
exclude: Vec::new(),
313+
accepts_unit_tests: true,
314+
expected_split: Err(failure(
315+
"S013",
316+
"selector 'order_status,tag:daily' intersects a unit test with ','; unit tests can only be selected whole, by name",
317+
None,
318+
)),
319+
},
276320
UnitTestSplitTestCase {
277321
description: "a stray trailing comma after a unit test reports the empty selector",
278322
select: texts(&["test:order_status,"]),

‎crates/sqlbuild-python/src/bindings/_helpers/clone/clone_pipeline.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::bindings::_helpers::records::ids::RecordId;
1616
/// The phase name of one target compile, before the target name.
1717
const COMPILE_PHASE_PREFIX: &str = "compile_";
1818

19-
/// The `ClonePipelineResult` fields after the two projects, in `run_clone_planning` order.
19+
/// The `ClonePipelineResult` fields after the two projects, in `timed_clone_planning` order.
2020
const PLANNED_FIELDS: [&str; 8] = [
2121
"clone_plan",
2222
"destination_source_entries",

‎crates/sqlbuild-python/src/bindings/_helpers/planner_entries/clone_plans.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,15 +512,15 @@ fn origin_source_entries<'py>(
512512
)
513513
}
514514

515-
/// `run_clone_planning`, with the seconds spent inspecting sources and planning.
515+
/// Plan a clone, with the seconds spent inspecting sources and planning.
516516
pub(crate) fn timed_clone_planning<'py>(
517517
py: Python<'py>,
518518
kwargs: Option<Bound<'py, PyDict>>,
519519
) -> PyResult<(Bound<'py, PyTuple>, PhaseTimings)> {
520520
let started = std::time::Instant::now();
521521
let args = KeywordArguments::read(
522522
py,
523-
"run_clone_planning",
523+
"timed_clone_planning",
524524
kwargs,
525525
(
526526
&[

‎tests/integration/src/sqlbuild/integrations/dbt/test_plan.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,25 @@
258258
expected_sqlbuild_skip_reason=None,
259259
expected_path_translations=(),
260260
),
261+
RealDbtInteropPlanTestCase(
262+
description="translates backslash model path selector for real SQLBuild project",
263+
args=("--select", "path:models\\marts"),
264+
sqlbuild_model_contents_by_relative_path={
265+
"marts/mart_orders.sql": "MODEL (description 'Test model mart_orders.');\n\nselect 1 as order_id\n",
266+
"staging/stg_local.sql": "MODEL (description 'Test model stg_local.');\n\nselect 1 as order_id\n",
267+
},
268+
expected_sqlbuild_model_names=("mart_orders",),
269+
expected_sqlbuild_command_argvs=(("sqb", "plan", "--select", "mart_orders"),),
270+
expected_dbt_selected_unique_ids=(),
271+
expected_dbt_required_unique_ids=(),
272+
expected_dbt_required_selector_terms=(),
273+
expected_supplemental_dbt_command_argvs=(),
274+
expected_dbt_anchor_terms=(),
275+
expected_dbt_anchor_unique_ids_by_term={},
276+
expected_dbt_skip_reason=DbtInteropSkipReason.NO_DBT_WORK,
277+
expected_sqlbuild_skip_reason=None,
278+
expected_path_translations=(("path:models\\marts", "path:models/marts"),),
279+
),
261280
RealDbtInteropPlanTestCase(
262281
description="preserves routed SQLBuild cursor args in real plan argv",
263282
args=("--select", "local_only", "--start-cursor-int", "10"),

0 commit comments

Comments
 (0)