Skip to content

Commit

Permalink
Merge pull request #81 from dbt-labs/group-without-selection-syntax-e…
Browse files Browse the repository at this point in the history
…rror

create empty no selection syntax provided to group command
  • Loading branch information
dave-connors-3 authored Jun 29, 2023
2 parents b9e55f1 + 8460d39 commit 06892d2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
9 changes: 6 additions & 3 deletions dbt_meshify/utilities/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ def _generate_resource_group(
resource_type=NodeType.Group,
)

nodes = self.project.select_resources(
select=select, exclude=exclude, selector=selector, output_key="unique_id"
)
if not (select or exclude or selector):
nodes = set()
else:
nodes = self.project.select_resources(
select=select, exclude=exclude, selector=selector, output_key="unique_id"
)

# Check if any of the selected nodes are already in a group of a different name. If so, raise an exception.
nodes = set(filter(lambda x: not x.startswith("source"), nodes))
Expand Down
30 changes: 23 additions & 7 deletions tests/integration/test_create_group_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,31 @@


@pytest.mark.parametrize(
"model_yml,start_group_yml,end_group_yml",
"model_yml,select,start_group_yml,end_group_yml",
[
(model_yml_shared_model, group_yml_empty_file, expected_group_yml_no_group),
(model_yml_shared_model, group_yml_existing_groups, expected_group_yml_existing_groups),
(model_yml_shared_model, group_yml_group_predefined, expected_group_yml_no_group),
(
model_yml_shared_model,
"shared_model",
group_yml_empty_file,
expected_group_yml_no_group,
),
(
model_yml_shared_model,
"shared_model",
group_yml_existing_groups,
expected_group_yml_existing_groups,
),
(
model_yml_shared_model,
"shared_model",
group_yml_group_predefined,
expected_group_yml_no_group,
),
(model_yml_shared_model, "", group_yml_empty_file, expected_group_yml_no_group),
],
ids=["1", "2", "3"],
ids=["1", "2", "3", "4"],
)
def test_create_group_command(model_yml, start_group_yml, end_group_yml):
def test_create_group_command(model_yml, select, start_group_yml, end_group_yml):
group_yml_file = proj_path / "models" / "_groups.yml"
model_yml_file = proj_path / "models" / "_models.yml"

Expand All @@ -52,7 +68,7 @@ def test_create_group_command(model_yml, start_group_yml, end_group_yml):
[
"test_group",
"--select",
"shared_model",
select,
"--project-path",
proj_path_string,
"--owner-name",
Expand Down

0 comments on commit 06892d2

Please sign in to comment.