Skip to content

Commit 833c68c

Browse files
Move test to CLI level and verify import pipeline errors are handled
Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
1 parent 79d9ebd commit 833c68c

2 files changed

Lines changed: 23 additions & 21 deletions

File tree

tests/usethis/_integrations/ci/bitbucket/test_steps.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -648,27 +648,6 @@ def test_script_items_canonical_order_with_existing_non_canonical_items(
648648
"""
649649
)
650650

651-
def test_import_pipeline_raises_error(self, tmp_path: Path):
652-
"""Test that add_bitbucket_step_in_default raises error for import pipelines."""
653-
# Arrange
654-
(tmp_path / "bitbucket-pipelines.yml").write_text(
655-
"""\
656-
image: atlassian/default-image:3
657-
pipelines:
658-
default:
659-
import: shared-pipeline:master:share-pipeline-1
660-
"""
661-
)
662-
663-
# Act, Assert
664-
with change_cwd(tmp_path), pytest.raises(UnexpectedImportPipelineError):
665-
add_bitbucket_step_in_default(
666-
Step(
667-
name="Greeting",
668-
script=Script(["echo 'Hello, world!'"]),
669-
)
670-
)
671-
672651

673652
class TestRemoveBitbucketStepFromDefault:
674653
def test_remove_remove_one_step(self, tmp_path: Path):

tests/usethis/_ui/interface/test_interface_ci.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,26 @@ def test_invalid_pyproject_toml(self, tmp_path: Path):
135135

136136
# Assert
137137
assert result.exit_code == 1, result.output
138+
139+
def test_import_pipeline_error_handled(self, tmp_path: Path):
140+
"""Test that import pipeline errors are handled gracefully at CLI level."""
141+
# Arrange - create a bitbucket-pipelines.yml with an import pipeline
142+
(tmp_path / "bitbucket-pipelines.yml").write_text(
143+
"""\
144+
image: atlassian/default-image:3
145+
pipelines:
146+
default:
147+
import: shared-pipeline:master:share-pipeline-1
148+
"""
149+
)
150+
# Add a tool so update_bitbucket_steps gets called
151+
(tmp_path / "pytest.ini").touch()
152+
153+
# Act
154+
runner = CliRunner()
155+
with change_cwd(tmp_path):
156+
result = runner.invoke_safe(app, ["--backend=none"])
157+
158+
# Assert - error should be caught and handled, not propagate as unhandled exception
159+
assert result.exit_code == 1, result.output
160+
assert "import pipeline" in result.output.lower()

0 commit comments

Comments
 (0)