From 669a20cbf21b9be4cc72f1a7c78afcbc816087bf Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Sat, 4 Oct 2025 22:45:11 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=85=20Add=20test=20to=20make=20sure?= =?UTF-8?q?=20.fastapicloudignore=20can=20override=20.gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_archive.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_archive.py b/tests/test_archive.py index 24bf4f45..68bc9162 100644 --- a/tests/test_archive.py +++ b/tests/test_archive.py @@ -57,6 +57,7 @@ def test_archive_preserves_relative_paths(tmp_path: Path) -> None: assert names == ["src/app/main.py"] + def test_archive_respects_fastapicloudignore(tmp_path: Path) -> None: """Should exclude files specified in .fastapicloudignore.""" # Create test files @@ -79,3 +80,26 @@ def test_archive_respects_fastapicloudignore(tmp_path: Path) -> None: "main.py", "config.py", } +def test_archive_respects_fastapicloudignore_unignore(tmp_path: Path) -> None: + """Test we can use .fastapicloudignore to unignore files inside .gitignore""" + # Create test files + (tmp_path / "main.py").write_text("print('hello')") + (tmp_path / "static/build").mkdir(exist_ok=True, parents=True) + (tmp_path / "static/build/style.css").write_text("body { background: #bada55 }") + # Rignore needs a .git folder to make .gitignore work + (tmp_path / ".git").mkdir(exist_ok=True, parents=True) + (tmp_path / ".gitignore").write_text("build/") + + # Create .fastapicloudignore file + (tmp_path / ".fastapicloudignore").write_text("!static/build") + + # Create archive + tar_path = archive(tmp_path) + + # Verify ignored files are excluded + with tarfile.open(tar_path, "r") as tar: + names = tar.getnames() + assert set(names) == { + "main.py", + "static/build/style.css" + } From e4980eea612710ca61dcebd20e07a5917cbeb199 Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Mon, 6 Oct 2025 10:41:55 +0100 Subject: [PATCH 2/2] Format --- tests/test_archive.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/test_archive.py b/tests/test_archive.py index 68bc9162..8276a007 100644 --- a/tests/test_archive.py +++ b/tests/test_archive.py @@ -57,7 +57,6 @@ def test_archive_preserves_relative_paths(tmp_path: Path) -> None: assert names == ["src/app/main.py"] - def test_archive_respects_fastapicloudignore(tmp_path: Path) -> None: """Should exclude files specified in .fastapicloudignore.""" # Create test files @@ -80,6 +79,8 @@ def test_archive_respects_fastapicloudignore(tmp_path: Path) -> None: "main.py", "config.py", } + + def test_archive_respects_fastapicloudignore_unignore(tmp_path: Path) -> None: """Test we can use .fastapicloudignore to unignore files inside .gitignore""" # Create test files @@ -99,7 +100,4 @@ def test_archive_respects_fastapicloudignore_unignore(tmp_path: Path) -> None: # Verify ignored files are excluded with tarfile.open(tar_path, "r") as tar: names = tar.getnames() - assert set(names) == { - "main.py", - "static/build/style.css" - } + assert set(names) == {"main.py", "static/build/style.css"}