Skip to content

Commit

Permalink
add tests for all render instances
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Jul 2, 2024
1 parent 6d6bc21 commit a4042d4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
50 changes: 49 additions & 1 deletion tests/functional/adapter/empty/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@
""".strip()


SCHEMA = """
version: 2
seeds:
- name: my_seed
description: "This is my_seed"
columns:
- name: id
description: "This is my_seed.my_id"
"""

CONTROL = """
select * from {{ ref("my_seed") }}
"""


GET_COLUMNS_IN_RELATION = """
{{ config(materialized="table") }}
select {{ adapter.get_columns_in_relation(ref("my_seed"))|length }} as get_columns_in_relation
{% set columns = adapter.get_columns_in_relation(ref("my_seed")) %}
select * from {{ ref("my_seed") }}
"""


Expand All @@ -22,3 +34,39 @@
{{ alter_column_type(ref("my_seed"), "MY_VALUE", "string") }}
select * from {{ ref("my_seed") }}
"""


ALTER_RELATION_COMMENT = """
{{ config(
materialized="table",
persist_docs={"relations": True},
) }}
select * from {{ ref("my_seed") }}
"""


ALTER_COLUMN_COMMENT = """
{{ config(
materialized="table",
persist_docs={"columns": True},
) }}
select * from {{ ref("my_seed") }}
"""


ALTER_RELATION_ADD_REMOVE_COLUMNS = """
{{ config(materialized="table") }}
{% set my_seed = adapter.Relation.create(this.database, this.schema, "my_seed", "table") %}
{% set my_column = api.Column("my_column", "varchar") %}
{% do alter_relation_add_remove_columns(my_seed, [my_column], none) %}
{% do alter_relation_add_remove_columns(my_seed, none, [my_column]) %}
select * from {{ ref("my_seed") }}
"""


TRUNCATE_RELATION = """
{{ config(materialized="table") }}
{% set my_seed = adapter.Relation.create(this.database, this.schema, "my_seed", "table") %}
{{ truncate_relation(my_seed) }}
select * from {{ ref("my_seed") }}
"""
9 changes: 9 additions & 0 deletions tests/functional/adapter/empty/test_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ def seeds(self):
@pytest.fixture(scope="class")
def models(self):
return {
"schema.yml": _models.SCHEMA,
"control.sql": _models.CONTROL,
"get_columns_in_relation.sql": _models.GET_COLUMNS_IN_RELATION,
"alter_column_type.sql": _models.ALTER_COLUMN_TYPE,
"alter_relation_comment.sql": _models.ALTER_RELATION_COMMENT,
"alter_column_comment.sql": _models.ALTER_COLUMN_COMMENT,
"alter_relation_add_remove_columns.sql": _models.ALTER_RELATION_ADD_REMOVE_COLUMNS,
"truncate_relation.sql": _models.TRUNCATE_RELATION,
}

@pytest.fixture(scope="class", autouse=True)
Expand All @@ -36,6 +41,10 @@ def setup(self, project):
"control",
"get_columns_in_relation",
"alter_column_type",
"alter_relation_comment",
"alter_column_comment",
"alter_relation_add_remove_columns",
"truncate_relation",
],
)
def test_run(self, project, model):
Expand Down

0 comments on commit a4042d4

Please sign in to comment.