Skip to content

Commit 78c71b3

Browse files
committed
fail branch report command on main branch
1 parent 22a5de6 commit 78c71b3

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

infrahub_sdk/ctl/branch.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import sys
23
from datetime import datetime, timezone
34
from typing import TYPE_CHECKING
45

@@ -195,6 +196,10 @@ async def report( # noqa: PLR0915
195196
) -> None:
196197
"""Generate branch cleanup status report."""
197198

199+
if branch_name == "main":
200+
console.print("[red]Cannot create a report for the main branch!")
201+
sys.exit(1)
202+
198203
client = initialize_client()
199204

200205
# Fetch branch metadata first (needed for diff creation)

tests/unit/ctl/test_branch_report.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,15 @@ def test_branch_report_command_without_proposed_change(
199199
assert "No proposed changes for this branch" in result.stdout
200200

201201

202+
def test_branch_report_command_main_branch() -> None:
203+
"""Test branch report CLI command on main branch."""
204+
runner = CliRunner()
205+
result = runner.invoke(app, ["report", "main"])
206+
207+
assert result.exit_code == 1
208+
assert "Cannot create a report for the main branch!" in result.stdout
209+
210+
202211
@pytest.fixture
203212
async def schema_with_proposed_change() -> dict:
204213
"""Schema fixture that includes CoreProposedChange with is_draft."""

tests/unit/sdk/test_node.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,10 +1736,20 @@ async def test_update_input_data__with_relationships_01(
17361736
expected_result_with_property = {
17371737
"data": {
17381738
"id": "llllllll-llll-llll-llll-llllllllllll",
1739-
"name": {"is_protected": True, "is_visible": True, "value": "DFW", "updated_at": "2024-01-15T10:30:00.000000Z"},
1739+
"name": {
1740+
"is_protected": True,
1741+
"is_visible": True,
1742+
"value": "DFW",
1743+
"updated_at": "2024-01-15T10:30:00.000000Z",
1744+
},
17401745
"primary_tag": {"id": "gggggggg-gggg-gggg-gggg-gggggggggggg"},
17411746
"tags": [{"id": "gggggggg-gggg-gggg-gggg-gggggggggggg"}, {"id": "rrrrrrrr-rrrr-rrrr-rrrr-rrrrrrrrrrrr"}],
1742-
"type": {"is_protected": True, "is_visible": True, "value": "SITE","updated_at": "2024-01-15T10:30:00.000000Z"},
1747+
"type": {
1748+
"is_protected": True,
1749+
"is_visible": True,
1750+
"value": "SITE",
1751+
"updated_at": "2024-01-15T10:30:00.000000Z",
1752+
},
17431753
},
17441754
}
17451755

@@ -1900,10 +1910,20 @@ async def test_update_input_data_empty_relationship(
19001910
expected_result_with_property = {
19011911
"data": {
19021912
"id": "llllllll-llll-llll-llll-llllllllllll",
1903-
"name": {"is_protected": True, "is_visible": True, "value": "DFW", "updated_at": "2024-01-15T10:30:00.000000Z"},
1913+
"name": {
1914+
"is_protected": True,
1915+
"is_visible": True,
1916+
"value": "DFW",
1917+
"updated_at": "2024-01-15T10:30:00.000000Z",
1918+
},
19041919
"primary_tag": None,
19051920
"tags": [],
1906-
"type": {"is_protected": True, "is_visible": True, "value": "SITE", "updated_at": "2024-01-15T10:30:00.000000Z"},
1921+
"type": {
1922+
"is_protected": True,
1923+
"is_visible": True,
1924+
"value": "SITE",
1925+
"updated_at": "2024-01-15T10:30:00.000000Z",
1926+
},
19071927
},
19081928
}
19091929

0 commit comments

Comments
 (0)