-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add test setup * Use env variables in profile and add script to run tests * Add simple test on root model and add tear down script * Add github test workflow * Add some single tests, dependencies and, seeds * Rename models yml files to schema * Add properties to seeds, macro select_table and use macro on couchdb model * Rename schemas properties files, add more tests, rearange dependencies * Add sudo command * Move package.yml to base directory * Add instructions on how to run unit tests locally * Change titles structure --------- Co-authored-by: Maria Lorena Rodriguez Viruel <[email protected]>
- Loading branch information
Showing
20 changed files
with
340 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Test | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
dbt-unit-tests: | ||
name: Unit Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16.x | ||
- name: Get Docker Hub username | ||
id: get-docker-hub-username | ||
run: echo '::set-output name=dockerhub_username::${{ secrets.DOCKERHUB_USERNAME }}' | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
if: steps.get-docker-hub-username.outputs.dockerhub_username | ||
- name: Install PostgreSQL client | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install --yes postgresql-client | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.8" | ||
- name: Install dependencies | ||
run: | | ||
pip install dbt-postgres | ||
dbt deps | ||
- name: Setup test | ||
run: ./setup.sh | ||
working-directory: ./tests | ||
- name: Run dbt and tests | ||
run: ./run_dbt_tests.sh | ||
working-directory: ./tests | ||
- name: Cleanup | ||
run: ./tear_down.sh | ||
working-directory: ./tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
|
||
target/ | ||
dbt_modules/ | ||
dbt_packages/ | ||
logs/ | ||
*/.env | ||
*/dbt_packages/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% macro select_table(source_table, test_table) %} | ||
|
||
{% if target.name == 'test' %} | ||
|
||
{{ return(test_table) }} | ||
|
||
{% else %} | ||
|
||
{{ return(source_table) }} | ||
|
||
{% endif %} | ||
|
||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: raw_contacts | ||
columns: | ||
- name: doc | ||
tests: | ||
- not_null | ||
tests: | ||
- dbt_utils.fewer_rows_than: | ||
compare_model: ref('couchdb') | ||
- name: contactview_metadata | ||
columns: | ||
- name: uuid | ||
tests: | ||
- not_null | ||
- name: type | ||
tests: | ||
- not_null | ||
- accepted_values: | ||
values: | ||
[contact, clinic, district_hospital, health_center, person] | ||
tests: | ||
- dbt_utils.equal_rowcount: | ||
compare_model: ref('raw_contacts') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: household_visits | ||
tests: | ||
- dbt_utils.fewer_rows_than: | ||
compare_model: ref('couchdb') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: reports_by_location | ||
columns: | ||
- name: uuid | ||
tests: | ||
- not_null | ||
- name: longitude | ||
tests: | ||
- not_null | ||
- name: latitude | ||
tests: | ||
- not_null | ||
tests: | ||
- dbt_utils.equal_rowcount: | ||
compare_model: ref('reports') | ||
- name: reports | ||
columns: | ||
- name: uuid | ||
tests: | ||
- not_null | ||
tests: | ||
- dbt_utils.fewer_rows_than: | ||
compare_model: ref('couchdb') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version: 2 | ||
|
||
sources: | ||
- name: couchdb | ||
database: data | ||
schema: v1 | ||
tables: | ||
- name: couchdb | ||
models: | ||
- name: couchdb | ||
columns: | ||
- name: _id | ||
tests: | ||
- not_null | ||
- name: _rev | ||
tests: | ||
- not_null | ||
tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- _id | ||
- _rev |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: data_record | ||
tests: | ||
- dbt_utils.fewer_rows_than: | ||
compare_model: ref('couchdb') | ||
- name: person | ||
tests: | ||
- dbt_utils.fewer_rows_than: | ||
compare_model: ref('couchdb') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: chws | ||
tests: | ||
- dbt_utils.fewer_rows_than: | ||
compare_model: ref('couchdb') | ||
- dbt_utils.equal_rowcount: | ||
compare_model: ref('person') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
packages: | ||
- package: dbt-labs/dbt_utils | ||
version: 1.1.1 |
Oops, something went wrong.