Skip to content

Commit

Permalink
Prefer root namespace by default (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtcohen6 authored Oct 25, 2021
1 parent 8437887 commit f1deecc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/unit/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,14 +452,19 @@ def test_resolve_specific(config, manifest_extended, redshift_adapter, get_inclu
with pytest.raises(dbt.exceptions.CompilationException):
ctx['adapter'].dispatch('macro_a').macro

# root namespace is always preferred, unless search order is explicitly defined in 'dispatch' config
assert ctx['adapter'].dispatch('some_macro').macro is package_rs_macro
assert ctx['adapter'].dispatch('some_macro', 'dbt').macro is rs_macro
assert ctx['adapter'].dispatch('some_macro', 'dbt').macro is package_rs_macro
assert ctx['adapter'].dispatch('some_macro', 'root').macro is package_rs_macro

# override 'dbt' namespace, dispatch to 'root' first
# override 'dbt' namespace search order, dispatch to 'root' first
ctx['adapter'].config.dispatch = [{'macro_namespace': 'dbt', 'search_order': ['root', 'dbt']}]
assert ctx['adapter'].dispatch('some_macro', macro_namespace = 'dbt').macro is package_rs_macro

# override 'root' namespace, dispatch to 'dbt' first
# override 'dbt' namespace search order, dispatch to 'dbt' only
ctx['adapter'].config.dispatch = [{'macro_namespace': 'dbt', 'search_order': ['dbt']}]
assert ctx['adapter'].dispatch('some_macro', macro_namespace = 'dbt').macro is rs_macro

# override 'root' namespace search order, dispatch to 'dbt' first
ctx['adapter'].config.dispatch = [{'macro_namespace': 'root', 'search_order': ['dbt', 'root']}]
assert ctx['adapter'].dispatch('some_macro', macro_namespace='root').macro is rs_macro
assert ctx['adapter'].dispatch('some_macro', macro_namespace = 'root').macro is rs_macro

0 comments on commit f1deecc

Please sign in to comment.