The problem I’m having
I would like to access (or just log out) all the models derived from the --select and --exclude command line arguments. The idea is to have a macro which will be executed only if dbt test is run, and it will apply OK and FAIL tags on those models that were subject to the run.
The context of why I’m trying to do this
What I’ve already tried
Some example code or error messages
{% macro apply_tests_pass(results) %}
{{ log('apply_tests_pass') }}
{% if execute and flags.WHICH == 'test' %}
{{ log('execute of tests') }}
{{ log(context['context']) }}
{{ log('selected resources:') }}
-- this only logs out selected tests:
{{ log(context['context']['selected_resources']) }}
{% set passed_tests = results | selectattr('status', 'equalto', 'pass') | list %}
{% set failed_tests = results | selectattr('status', 'equalto', 'fail') | list %}
{#
-- Here I have the failed and passed refs. But I would like to get also all the other refs from the test run.
-- Lets say I have models/base/modelA, models/base/modelB, models/stage/tableA and models/stage/tableB
-- Let say tests are defined on modelA in base and stage.
-- If somebody runs dbt test --select /models/base
-- I want to get the list of all possible models, so modelB and model A
#}