Skip to content

Commit

Permalink
fix(edge-v2): Migrate only Edge API-enabled projects (#4556)
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 authored Aug 29, 2024
1 parent 3e6b96f commit 9c5ff4f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/edge_api/management/commands/migrate_to_edge_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def handle(self, *args: Any, **options: Any) -> str | None:
edge_v2_migration_status__in=(
EdgeV2MigrationStatus.NOT_STARTED,
EdgeV2MigrationStatus.INCOMPLETE,
)
),
enable_dynamo_db=True,
).values_list("id", flat=True):
try:
migrate_project_environments_to_v2(project_id)
Expand Down
37 changes: 37 additions & 0 deletions api/tests/unit/edge_api/test_unit_edge_api_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ def test_migrate_to_edge_v2__new_projects__dont_migrate(
name="edge_v2_not_started",
organisation=project.organisation,
edge_v2_migration_status=EdgeV2MigrationStatus.NOT_STARTED,
enable_dynamo_db=True,
),
Project(
name="edge_v2_incomplete",
organisation=project.organisation,
edge_v2_migration_status=EdgeV2MigrationStatus.INCOMPLETE,
enable_dynamo_db=True,
),
],
)
Expand All @@ -39,3 +41,38 @@ def test_migrate_to_edge_v2__new_projects__dont_migrate(
)
# the migrated `project` was not redundantly migrated
migrate_project_environments_to_v2_mock.call_count == len(unmigrated_projects)


def test_migrate_to_edge_v2__core_projects__dont_migrate(
mocker: MockerFixture, project: Project
) -> None:
# Given
# unmigrated Core projects are present
Project.objects.bulk_create(
[
Project(
name="core__edge_v2_not_started",
organisation=project.organisation,
edge_v2_migration_status=EdgeV2MigrationStatus.NOT_STARTED,
enable_dynamo_db=False,
),
Project(
name="core__edge_v2_incomplete",
organisation=project.organisation,
edge_v2_migration_status=EdgeV2MigrationStatus.INCOMPLETE,
enable_dynamo_db=False,
),
],
)

migrate_project_environments_to_v2_mock = mocker.patch(
"edge_api.management.commands.migrate_to_edge_v2.migrate_project_environments_to_v2",
autospec=True,
)

# When
call_command("migrate_to_edge_v2")

# Then
# unmigrated Core projects were not migrated
migrate_project_environments_to_v2_mock.assert_not_called()

0 comments on commit 9c5ff4f

Please sign in to comment.