From d9578f95586c8426f503ef6c52bda5d7861ed93c Mon Sep 17 00:00:00 2001 From: Dave Connors Date: Sun, 5 May 2024 11:10:56 -0500 Subject: [PATCH] update tests --- tests/integration/test_version_command.py | 10 +++++++++- tests/sql_and_yml_fixtures.py | 11 +++++++++++ tests/unit/test_add_version_to_yml.py | 18 ++++++++++++++---- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/tests/integration/test_version_command.py b/tests/integration/test_version_command.py index 864a606..c44a46f 100644 --- a/tests/integration/test_version_command.py +++ b/tests/integration/test_version_command.py @@ -10,6 +10,7 @@ from tests.dbt_project_utils import setup_test_project, teardown_test_project from ..sql_and_yml_fixtures import ( + expected_versioned_model_yml_increment_latest_version, expected_versioned_model_yml_increment_prerelease_version, expected_versioned_model_yml_increment_prerelease_version_with_second_prerelease, expected_versioned_model_yml_increment_version_no_prerelease, @@ -239,10 +240,17 @@ def test_bump_version_fails_when_no_versions_present( expected_versioned_model_yml_increment_prerelease_version, ["shared_model_v1.sql", "shared_model_v2.sql"], ["shared_model_v1.sql", "shared_model_v2.sql", "shared_model_v3.sql"], + ["--increment"], + ), + ( + expected_versioned_model_yml_increment_version_with_prerelease, + expected_versioned_model_yml_increment_latest_version, + ["shared_model_v1.sql", "shared_model_v2.sql"], + ["shared_model_v1.sql", "shared_model_v2.sql", "shared_model_v3.sql"], ["--latest"], ), ], - ids=["1", "2", "3", "4", "5"], + ids=["1", "2", "3", "4", "5", "6"], ) def test_bump_version_in_yml( start_yml, end_yml, start_files, expected_files, command_options, project diff --git a/tests/sql_and_yml_fixtures.py b/tests/sql_and_yml_fixtures.py index 0517af4..251dbcb 100644 --- a/tests/sql_and_yml_fixtures.py +++ b/tests/sql_and_yml_fixtures.py @@ -262,6 +262,17 @@ - v: 3 """ +expected_versioned_model_yml_increment_latest_version = """ +models: + - name: shared_model + latest_version: 3 + description: "this is a test model" + versions: + - v: 1 + - v: 2 + - v: 3 +""" + expected_versioned_model_yml_prerelease_defined_in = """ models: - name: shared_model diff --git a/tests/unit/test_add_version_to_yml.py b/tests/unit/test_add_version_to_yml.py index 2313e12..4c4d925 100644 --- a/tests/unit/test_add_version_to_yml.py +++ b/tests/unit/test_add_version_to_yml.py @@ -4,7 +4,7 @@ import yaml from dbt_meshify.storage.file_content_editors import ResourceFileEditor -from dbt_meshify.utilities.versioner import ModelVersioner +from dbt_meshify.utilities.versioner import LatestVersionBehavior, ModelVersioner from ..dbt_project_fixtures import model, project # noqa: F401 from ..sql_and_yml_fixtures import ( @@ -59,7 +59,9 @@ def test_add_version_to_model_yml_increment_version_no_prerelease( self, model, project, file_manager # noqa: F811 ): versioner = ModelVersioner(project=project, file_manager=file_manager) - changes = list(versioner.bump_version(model)) + changes = list( + versioner.bump_version(model, latest_version_behavior=LatestVersionBehavior.Increment) + ) yml_dict = ResourceFileEditor.update_resource( properties=read_yml(model_yml_increment_version), change=changes[0] ) @@ -70,7 +72,9 @@ def test_add_version_to_model_yml_increment_version_with_prerelease( self, model, project, file_manager # noqa: F811 ): versioner = ModelVersioner(project=project, file_manager=file_manager) - changes = list(versioner.bump_version(model, prerelease=True)) + changes = list( + versioner.bump_version(model, latest_version_behavior=LatestVersionBehavior.Prerelease) + ) yml_dict = ResourceFileEditor.update_resource( properties=read_yml(model_yml_increment_version), change=changes[0] ) @@ -81,7 +85,13 @@ def test_add_version_to_model_yml_increment_version_defined_in( self, model, project, file_manager # noqa: F811 ): versioner = ModelVersioner(project=project, file_manager=file_manager) - changes = list(versioner.bump_version(model, defined_in="daves_model", prerelease=True)) + changes = list( + versioner.bump_version( + model, + latest_version_behavior=LatestVersionBehavior.Prerelease, + defined_in="daves_model", + ) + ) yml_dict = ResourceFileEditor.update_resource( properties=read_yml(model_yml_increment_version), change=changes[0] )