Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-connors-3 committed May 5, 2024
1 parent d3999e8 commit d9578f9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
10 changes: 9 additions & 1 deletion tests/integration/test_version_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions tests/sql_and_yml_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 14 additions & 4 deletions tests/unit/test_add_version_to_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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]
)
Expand All @@ -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]
)
Expand All @@ -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]
)
Expand Down

0 comments on commit d9578f9

Please sign in to comment.