Skip to content

Commit

Permalink
test: implement initial testing framework
Browse files Browse the repository at this point in the history
  • Loading branch information
cverhoef committed Oct 6, 2023
1 parent 1d60251 commit f573066
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# compiled code & logs
**/target/
**/logs/
# package folder
**/dbt_packages/
# dbt folders that are not used
**/snapshots/
**/analysis/
**/data/
# user specific file
**/.user.yml

# MacOS specific files
.DS_Store
5 changes: 5 additions & 0 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: 'pm_utils_integration_tests'
version: '1.0.0'
config-version: 2

profile: 'integration_tests'
3 changes: 3 additions & 0 deletions integration_tests/macros/tests.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% test equal_value(model, actual, expected) %}
select * from {{ model }} where {{ actual }} != {{ expected }}
{% endtest %}
11 changes: 11 additions & 0 deletions integration_tests/models/schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2

models:
- name: test_concat
tests:
- equal_value:
actual: '"Two_text_fields"'
expected: '"Two_text_fields_expected"'
- equal_value:
actual: '"One_null"'
expected: '"One_null_expected"'
16 changes: 16 additions & 0 deletions integration_tests/models/test_concat.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
with Input_data as (
select
'A' as "Column_A",
'B' as "Column_B",
null as "Column_C"
)

select
{# Concatenate two text fields (basic scenario) #}
{{ pm_utils.concat('"Column_A"', '"Column_B"') }} as "Two_text_fields",
'AB' as "Two_text_fields_expected",

{# Concatenate two fields of which one is null #}
{{ pm_utils.concat('"Column_A"', '"Column_C"') }} as "One_null",
'A' as "One_null_expected"
from Input_data
2 changes: 2 additions & 0 deletions integration_tests/packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- local: ../

0 comments on commit f573066

Please sign in to comment.