Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yu-iskw/dbt-unittest
A dbt package provides macros for unit testing, inspired by python's unittest module
https://github.com/yu-iskw/dbt-unittest
dbt dbt-package unit-testing unittest
Last synced: 4 days ago
JSON representation
A dbt package provides macros for unit testing, inspired by python's unittest module
- Host: GitHub
- URL: https://github.com/yu-iskw/dbt-unittest
- Owner: yu-iskw
- License: apache-2.0
- Created: 2022-07-06T04:55:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-28T05:13:45.000Z (9 days ago)
- Last Synced: 2024-10-28T08:34:44.276Z (9 days ago)
- Topics: dbt, dbt-package, unit-testing, unittest
- Language: Shell
- Homepage: https://docs.getdbt.com/blog/unit-testing-dbt-packages
- Size: 111 KB
- Stars: 23
- Watchers: 2
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# dbt-unittest
This is a dbt package to enhance dbt package development by providing unit testing macros.- [Installation Instructions](#installation-instructions)
- [Requirements](#requirements)
- [Macros in the dbt package](#macros-in-the-dbt-package)
* [`assert_true`](#assert_true)
* [`assert_false`](#assert_false)
* [`assert_is_none`](#assert_is_none)
* [`assert_is_not_none`](#assert_is_not_none)
* [`assert_equals`](#assert_equals)
* [`assert_not_equals`](#assert_not_equals)
* [`assert_in`](#assert_in)
* [`assert_not_in`](#assert_not_in)
* [`assert_list_equals`](#assert_list_equals)
* [`assert_dict_equals`](#assert_dict_equals)## Installation Instructions
Check [dbt Hub](https://hub.getdbt.com/yu-iskw/dbt_unittest/latest/) for the latest installation instructions.## Requirements
- dbt-core: 1.0.0 or later## Macros in the dbt package
### `assert_true`
Test that expr is true.**Usage:**
```sql
{{ dbt_unittest.assert_true(true) }}
{{ dbt_unittest.assert_true(1 == 1) }}
```### `assert_false`
Test that expr is false.**Usage:**
```sql
{{ dbt_unittest.assert_false(false) }}
{{ dbt_unittest.assert_false(1 != 1) }}
```### `assert_is_none`
Test that expr is None.**Usage:**
```sql
{{ dbt_unittest.assert_is_none(none) }}
```### `assert_is_not_none`
Test that expr is not None.**Usage:**
```sql
{{ dbt_unittest.assert_is_not_none(none) }}
```### `assert_equals`
Test that first and second are equal.
If the values do not compare equal, the test will fail.**Usage:**
```sql
{{ dbt_unittest.assert_equals("foo", "bar") }}
```### `assert_not_equals`
Test that first and second are not equal.
If the values do compare equal, the test will fail.**Usage:**
```sql
{{ dbt_unittest.assert_not_equals("foo", "bar") }}
```### `assert_in`
Test that member is in container.**Usage:**
```sql
{{ dbt_unittest.assert_in(1, [1, 2, 3]) }}
```### `assert_not_in`
Test that member is not in container.**Usage:**
```sql
{{ dbt_unittest.assert_not_in(4, [1, 2, 3]) }}
```### `assert_list_equals`
Tests that two lists are equal.**Usage:**
```sql
{{ dbt_unittest.assert_list_equals([1, 2, 3], [4, 5]) }}
```### `assert_dict_equals`
Test that two dictionaries are equal.**Usage:**
```sql
{{ dbt_unittest.assert_dict_equals({"k": 1}, {"k": 1}) }}
```## Contributors