-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add postflight to handle click exc and exit codes (#7212)
- Loading branch information
Showing
5 changed files
with
125 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Add exception handling in postflight decorator to address exit codes | ||
time: 2023-03-21T14:18:04.917329-05:00 | ||
custom: | ||
Author: stu-k | ||
Issue: "7010" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pytest | ||
|
||
from dbt.cli.main import cli | ||
from dbt.cli.requires import HandledExit | ||
|
||
|
||
good_sql = """ | ||
select 1 as fun | ||
""" | ||
|
||
bad_sql = """ | ||
someting bad | ||
""" | ||
|
||
|
||
class CliRunnerBase: | ||
def run_cli(self): | ||
ctx = cli.make_context(cli.name, ["run"]) | ||
return cli.invoke(ctx) | ||
|
||
|
||
class TestExitCodeZero(CliRunnerBase): | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return {"model_one.sql": good_sql} | ||
|
||
def test_no_exc_thrown(self, project): | ||
self.run_cli() | ||
|
||
|
||
class TestExitCodeOne(CliRunnerBase): | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return {"model_one.sql": bad_sql} | ||
|
||
def test_exc_thrown(self, project): | ||
with pytest.raises(HandledExit): | ||
self.run_cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pytest | ||
|
||
from dbt.tests.util import run_dbt | ||
|
||
|
||
model_one_sql = """ | ||
someting bad | ||
""" | ||
|
||
|
||
class TestHandledExit: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return {"model_one.sql": model_one_sql} | ||
|
||
def test_failed_run_does_not_throw(self, project): | ||
run_dbt(["run"], expect_pass=False) |