|
| 1 | +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | + |
| 3 | +"""Tests for FEATURE_BUNDLE_1 extension support in the CLI.""" |
| 4 | + |
| 5 | +import os |
| 6 | +from pathlib import Path |
| 7 | + |
| 8 | +import pytest |
| 9 | + |
| 10 | +from . import run_openjd_cli_main |
| 11 | + |
| 12 | +TEMPLATES_DIR = Path(__file__).parent / "templates" |
| 13 | + |
| 14 | + |
| 15 | +class TestFeatureBundle1: |
| 16 | + """Tests for FEATURE_BUNDLE_1 extension features.""" |
| 17 | + |
| 18 | + def test_python_syntax_sugar(self, capsys) -> None: |
| 19 | + """Test that Python syntax sugar works.""" |
| 20 | + template = TEMPLATES_DIR / "feature_bundle_1_python.yaml" |
| 21 | + outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) |
| 22 | + assert "Hello from Python!" in outerr.out |
| 23 | + |
| 24 | + def test_bash_syntax_sugar(self, capsys) -> None: |
| 25 | + """Test that Bash syntax sugar works.""" |
| 26 | + template = TEMPLATES_DIR / "feature_bundle_1_bash.yaml" |
| 27 | + outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) |
| 28 | + assert "Hello from Bash!" in outerr.out |
| 29 | + |
| 30 | + @pytest.mark.skipif(os.name != "nt", reason="PowerShell only available on Windows") |
| 31 | + def test_powershell_syntax_sugar(self, capsys) -> None: |
| 32 | + """Test that PowerShell syntax sugar works.""" |
| 33 | + template = TEMPLATES_DIR / "feature_bundle_1_powershell.yaml" |
| 34 | + outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) |
| 35 | + assert "Hello from PowerShell!" in outerr.out |
| 36 | + |
| 37 | + @pytest.mark.skipif(os.name != "nt", reason="cmd only available on Windows") |
| 38 | + def test_cmd_syntax_sugar(self, capsys) -> None: |
| 39 | + """Test that cmd syntax sugar works.""" |
| 40 | + template = TEMPLATES_DIR / "feature_bundle_1_cmd.yaml" |
| 41 | + outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) |
| 42 | + assert "Hello from Cmd!" in outerr.out |
| 43 | + |
| 44 | + def test_format_string_timeout(self, capsys) -> None: |
| 45 | + """Test that format string timeout is resolved.""" |
| 46 | + template = TEMPLATES_DIR / "feature_bundle_1_timeout.yaml" |
| 47 | + outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) |
| 48 | + assert "Running with timeout 5s" in outerr.out |
| 49 | + |
| 50 | + def test_extended_step_name(self, capsys) -> None: |
| 51 | + """Test that extended step names (>64 chars) work with extension.""" |
| 52 | + template = TEMPLATES_DIR / "feature_bundle_1_long_name.yaml" |
| 53 | + outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) |
| 54 | + assert "Long step name works!" in outerr.out |
| 55 | + |
| 56 | + def test_end_of_line_lf(self, capsys) -> None: |
| 57 | + """Test that endOfLine: LF produces LF-only line endings.""" |
| 58 | + template = TEMPLATES_DIR / "feature_bundle_1_eol.yaml" |
| 59 | + outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) |
| 60 | + # od -c output should show \n without \r |
| 61 | + assert "\\n" in outerr.out or "l i n e" in outerr.out |
| 62 | + |
| 63 | + def test_check_validates_extension(self, capsys) -> None: |
| 64 | + """Test that check command validates templates with extension.""" |
| 65 | + template = TEMPLATES_DIR / "feature_bundle_1_python.yaml" |
| 66 | + outerr = run_openjd_cli_main(capsys, args=["check", str(template)], expected_exit_code=0) |
| 67 | + assert "passes validation checks" in outerr.out |
0 commit comments