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

check_model_has_tests_by_name being applied to all models #219

Open
SantiASC opened this issue May 3, 2024 · 0 comments
Open

check_model_has_tests_by_name being applied to all models #219

SantiASC opened this issue May 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@SantiASC
Copy link

SantiASC commented May 3, 2024

Describe the bug
When using pre-commit and committing a change of a file in the root directory that is not related to a dbt model (i.e. change to the .pre-commit-config.yaml), the check_model_has_tests_by_name hook checks across all available models in the manifest.json, this happens even if an exclude argument has been specified.

Also, related to the --exclude argument, the example presented in HOOKS.md shows the following example:
args: ["--test-cnt", "1", "--exclude models/demo", "--"]
However, this syntax generates an error, I believe this should be updated to:
args: ["--test-cnt", "1", "--exclude", "models/demo", "--"]

To Reproduce
Steps to reproduce the behavior:

  1. Add pre-commit hook to .pre-commit-config.yaml
   - repo: https://github.com/dbt-checkpoint/dbt-checkpoint
    rev: v2.0.1
    hooks:
      - id: check-model-has-tests-by-name
        args: ["--tests", "unique=1","--exclude",  "^(?!models/).*" ,"--"]
  1. Stage and commit the .pre-commit-config.yaml change
  2. pre-commit fails with all models in the project that fail the criteria (i.e. all models that do not have a unique test)

Expected behavior
The expected behavior is that this test checks only for dbt models or corresponding properties yml files that are committed or that using the exclude argument we can specify which files should be excluded. For example using the regex expression "^(?!models/).*" would exclude committed changes that are not part of the models folder.

Version:
v2.0.1

Additional context
In this attached image you can see that check-model-has-test-by-name failed even when .pre-commit-config.yaml file was the only change. This is not specific to change to pre-commit-config file, changes to other files like project.yml also trigger this behavior.
test-by-name-result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant