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

Reset Remote on Assert commands #145

Merged
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
19 changes: 17 additions & 2 deletions spectacles/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def main():
args.client_secret,
args.port,
args.api_version,
args.remote_reset,
)


Expand Down Expand Up @@ -390,6 +391,13 @@ def _build_assert_subparser(
subparser.add_argument(
"--branch", action=EnvVarAction, env_var="LOOKER_GIT_BRANCH", required=True
)
subparser.add_argument(
"--remote-reset",
action="store_true",
help="When set to true, the SQL validator will tell Looker to reset the \
user's branch to the revision of the branch that is on the remote. \
WARNING: This will delete any uncommited changes in the user's workspace.",
)


def run_connect(
Expand All @@ -400,10 +408,17 @@ def run_connect(


def run_assert(
project, branch, base_url, client_id, client_secret, port, api_version
project, branch, base_url, client_id, client_secret, port, api_version, remote_reset
) -> None:
runner = Runner(
base_url, project, branch, client_id, client_secret, port, api_version
base_url,
project,
branch,
client_id,
client_secret,
port,
api_version,
remote_reset,
)
errors = runner.validate_data_tests()
if errors:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,8 @@ def test_bad_config_file_parameter(mock_parse_config, clean_env, parser):
SpectaclesException, match="not a valid configuration parameter"
):
parser.parse_args(["connect", "--config-file", "config.yml"])


def test_parse_remote_reset_with_assert(env, parser):
args = parser.parse_args(["assert", "--remote-reset"])
assert args.remote_reset