Skip to content
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

[Backport 1.5.latest] fix target-path not working for sources.json #7423

Merged
merged 2 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230419-142150.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fix dbt command missing target-path param
time: 2023-04-19T14:21:50.959786-07:00
custom:
Author: ChenyuLInx
Issue: "\t7411"
4 changes: 2 additions & 2 deletions core/dbt/cli/params.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pathlib import Path, PurePath
from pathlib import Path

import click
from dbt.cli.options import MultiOption
Expand Down Expand Up @@ -229,7 +229,7 @@
envvar=None,
help="Specify the output path for the JSON report. By default, outputs to 'target/sources.json'",
type=click.Path(file_okay=True, dir_okay=False, writable=True),
default=PurePath.joinpath(Path.cwd(), "target/sources.json"),
default=None,
)

partial_parse = click.option(
Expand Down
13 changes: 9 additions & 4 deletions tests/functional/sources/test_source_freshness.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,15 @@ def test_source_snapshot_freshness(self, project):


class TestSourceFreshnessSelection(SuccessfulSourceFreshnessTest):
def test_source_freshness_selection_select(self, project):
@pytest.fixture(scope="class")
def project_config_update(self, logs_dir):
return {
"target-path": logs_dir,
}

def test_source_freshness_selection_select(self, project, logs_dir):
"""Tests node selection using the --select argument."""
"""Also validate that specify a target-path works as expected."""
self._set_updated_at_to(project, timedelta(hours=-2))
# select source directly
results = self.run_dbt_with_vars(
Expand All @@ -198,13 +205,11 @@ def test_source_freshness_selection_select(self, project):
"freshness",
"--select",
"source:test_source.test_table",
"-o",
"target/pass_source.json",
],
)
assert len(results) == 1
assert results[0].status == "pass"
self._assert_freshness_results("target/pass_source.json", "pass")
self._assert_freshness_results(f"{logs_dir}/sources.json", "pass")


class TestSourceFreshnessExclude(SuccessfulSourceFreshnessTest):
Expand Down