Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CT-1630] Convert Column_types tests #6690

Merged
merged 6 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

9 changes: 0 additions & 9 deletions test/integration/056_column_type_tests/pg_models/model.sql

This file was deleted.

14 changes: 0 additions & 14 deletions test/integration/056_column_type_tests/pg_models/schema.yml

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions test/integration/056_column_type_tests/test_column_types.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# macros
macro_test_alter_column_type = """
-- Macro to alter a column type
{% macro test_alter_column_type(model_name, column_name, new_column_type) %}
{% set relation = ref(model_name) %}
{{ alter_column_type(relation, column_name, new_column_type) }}
{% endmacro %}
"""

macro_test_is_type_sql = """
{% macro simple_type_check_column(column, check) %}
{% if check == 'string' %}
{{ return(column.is_string()) }}
Expand Down Expand Up @@ -70,3 +79,35 @@
{% endfor %}
select * from (select 1 limit 0) as nothing
{% endtest %}
"""

# models/schema

model_sql = """
select
1::smallint as smallint_col,
2::integer as int_col,
3::bigint as bigint_col,
4.0::real as real_col,
5.0::double precision as double_col,
6.0::numeric as numeric_col,
'7'::text as text_col,
'8'::varchar(20) as varchar_col
"""

schema_yml = """
version: 2
models:
- name: model
tests:
- is_type:
column_map:
smallint_col: ['integer', 'number']
int_col: ['integer', 'number']
bigint_col: ['integer', 'number']
real_col: ['float', 'number']
double_col: ['float', 'number']
numeric_col: ['numeric', 'number']
text_col: ['string', 'not number']
varchar_col: ['string', 'not number']
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest
from dbt.tests.util import run_dbt
from dbt.tests.adapter.column_types.fixtures import macro_test_is_type_sql, model_sql, schema_yml


class BaseColumnTypes:
@pytest.fixture(scope="class")
def macros(self):
return {"test_is_type.sql": macro_test_is_type_sql}

def run_and_test(self):
results = run_dbt(["run"])
assert len(results) == 1
results = run_dbt(["test"])
assert len(results) == 1


class TestPostgresColumnTypes(BaseColumnTypes):
@pytest.fixture(scope="class")
def models(self):
return {"model.sql": model_sql, "schema.yml": schema_yml}

def test_run_and_test(self, project):
self.run_and_test()