@@ -72,20 +72,16 @@ def test_archive_preserves_relative_paths(src_path: Path, tar_path: Path) -> Non
7272
7373def test_archive_respects_fastapicloudignore (src_path : Path , tar_path : Path ) -> None :
7474 """Should exclude files specified in .fastapicloudignore."""
75- # Create test files
7675 (src_path / "main.py" ).write_text ("print('hello')" )
7776 (src_path / "config.py" ).write_text ("CONFIG = 'value'" )
7877 (src_path / "secrets.env" ).write_text ("SECRET_KEY=xyz" )
7978 (src_path / "data" ).mkdir ()
8079 (src_path / "data" / "file.txt" ).write_text ("data" )
8180
82- # Create .fastapicloudignore file
8381 (src_path / ".fastapicloudignore" ).write_text ("secrets.env\n data/\n " )
8482
85- # Create archive
8683 archive (src_path , tar_path )
8784
88- # Verify ignored files are excluded
8985 with tarfile .open (tar_path , "r" ) as tar :
9086 names = tar .getnames ()
9187 assert set (names ) == {
@@ -98,21 +94,39 @@ def test_archive_respects_fastapicloudignore_unignore(
9894 src_path : Path , tar_path : Path
9995) -> None :
10096 """Test we can use .fastapicloudignore to unignore files inside .gitignore"""
101- # Create test files
10297 (src_path / "main.py" ).write_text ("print('hello')" )
98+
99+ (src_path / "ignore_me.txt" ).write_text ("You should ignore me" )
100+
103101 (src_path / "static/build" ).mkdir (exist_ok = True , parents = True )
104102 (src_path / "static/build/style.css" ).write_text ("body { background: #bada55 }" )
103+
105104 # Rignore needs a .git folder to make .gitignore work
106105 (src_path / ".git" ).mkdir (exist_ok = True , parents = True )
107- (src_path / ".gitignore" ).write_text ("build /" )
106+ (src_path / ".gitignore" ).write_text ("ignore_me.txt \n build /" )
108107
109- # Create .fastapicloudignore file
110108 (src_path / ".fastapicloudignore" ).write_text ("!static/build" )
111109
112- # Create archive
113110 archive (src_path , tar_path )
114111
115- # Verify ignored files are excluded
116112 with tarfile .open (tar_path , "r" ) as tar :
117113 names = tar .getnames ()
118114 assert set (names ) == {"main.py" , "static/build/style.css" }
115+
116+
117+ def test_archive_includes_hidden_files (src_path : Path , tar_path : Path ) -> None :
118+ """Should include hidden files in the archive by default."""
119+ (src_path / "main.py" ).write_text ("print('hello')" )
120+ (src_path / ".env" ).write_text ("SECRET_KEY=xyz" )
121+ (src_path / ".config" ).mkdir ()
122+ (src_path / ".config" / "settings.json" ).write_text ('{"setting": "value"}' )
123+
124+ archive (src_path , tar_path )
125+
126+ with tarfile .open (tar_path , "r" ) as tar :
127+ names = tar .getnames ()
128+ assert set (names ) == {
129+ "main.py" ,
130+ ".env" ,
131+ ".config/settings.json" ,
132+ }
0 commit comments