Skip to content

Commit

Permalink
fix target dir behavior with sources.json (#7412) (#7423)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Apr 20, 2023
1 parent 437870e commit 1d24e94
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
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

0 comments on commit 1d24e94

Please sign in to comment.