Skip to content

Commit

Permalink
Run tests only on test command
Browse files Browse the repository at this point in the history
  • Loading branch information
psousa50 committed Jan 5, 2024
1 parent 68b4b30 commit c8b3594
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 39 deletions.
2 changes: 1 addition & 1 deletion macros/tests.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% macro test(model_name, test_description='(no description)', options={}) %}
{{ dbt_unit_testing.ref_tested_model(model_name) }}

{% if execute %}
{% if execute and flags.WHICH == 'test' %}
{% set mocks_and_expectations_json_str = caller() %}
{% set model_version = kwargs["version"] | default(kwargs["v"]) | default(none) %}
{% set model_node = {"package_name": model.package_name, "name": model_name, "version": model_version} %}
Expand Down
36 changes: 0 additions & 36 deletions run-test-on-dbt-version.sh

This file was deleted.

6 changes: 4 additions & 2 deletions run-tests-on-dbt-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ TEST_SCRIPT="$1"
PROFILE="$2"
DBT_VERSION=$3

echo "Running $TEST_SCRIPT on dbt $DBT_VERSION with profile $PROFILE"

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
VENV_NAME="venv-$PROFILE"
VENV_FOLDER="$SCRIPT_DIR/$VENV_NAME"

rm -rf "$VENV_FOLDER"
python3 -m venv "$VENV_FOLDER"

source "$VENV_FOLDER/bin/activate"

pip install --upgrade pip setuptools
pip install "dbt-$PROFILE==$DBT_VERSION"

source "$VENV_FOLDER/bin/activate"

"$SCRIPT_DIR/$TEST_SCRIPT.sh" "$PROFILE" "$DBT_VERSION"

0 comments on commit c8b3594

Please sign in to comment.