From 4941e699df65d0a4e58a67d51a654aad1daf186e Mon Sep 17 00:00:00 2001 From: proletarius101 Date: Sun, 2 Jun 2024 23:27:58 +0800 Subject: [PATCH] test(deploy): make sure the APK file is not uploaded in the index only mode --- tests/deploy.TestCase | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/tests/deploy.TestCase b/tests/deploy.TestCase index 9baaf5dc..5cbd978c 100755 --- a/tests/deploy.TestCase +++ b/tests/deploy.TestCase @@ -925,8 +925,9 @@ class DeployTest(unittest.TestCase): os.chdir(self.testdir) repo = Path('repo') repo.mkdir(parents=True) - files_in_repo = fdroidserver.deploy.INDEX_FILES + ['Sym.apk'] - for filename in files_in_repo: + fake_apk = 'Sym.apk' + fake_files = fdroidserver.deploy.INDEX_FILES + [fake_apk] + for filename in fake_files: fake_file = repo / filename with fake_file.open('w') as fp: fp.write('not a real one, but has the right filename') @@ -939,7 +940,7 @@ class DeployTest(unittest.TestCase): Path(self.testdir) / 'verify', ) - for filename in files_in_repo: + for filename in fake_files: remote_file = f"fdroid/{repo_section}/{filename}" self.assertIsNotNone(verify_repo.working_tree_dir) @@ -977,8 +978,9 @@ class DeployTest(unittest.TestCase): os.chdir(self.testdir) repo = Path('repo') repo.mkdir(parents=True) - files_in_repo = fdroidserver.deploy.INDEX_FILES - for filename in files_in_repo: + fake_apk = 'Sym.apk' + fake_files = fdroidserver.deploy.INDEX_FILES + [fake_apk] + for filename in fake_files: fake_file = repo / filename with fake_file.open('w') as fp: fp.write('not a real one, but has the right filename') @@ -991,7 +993,7 @@ class DeployTest(unittest.TestCase): Path(self.testdir) / 'verify', ) - for filename in files_in_repo: + for filename in fdroidserver.deploy.INDEX_FILES: remote_file = f"fdroid/{repo_section}/{filename}" self.assertIsNotNone(verify_repo.working_tree_dir) @@ -1000,6 +1002,13 @@ class DeployTest(unittest.TestCase): (Path(verify_repo.working_tree_dir) / remote_file).exists() ) + # Should not have the APK file + remote_file = f"fdroid/{repo_section}/{fake_apk}" + if verify_repo.working_tree_dir is not None: + self.assertFalse( + (Path(verify_repo.working_tree_dir) / remote_file).exists() + ) + def test_upload_to_servergitmirror_in_index_only_mode(self): # setup parameters for this test run fdroidserver.deploy.options = mock.Mock() @@ -1026,7 +1035,9 @@ class DeployTest(unittest.TestCase): fdroid_dir = local_git_repo_path / 'fdroid' repo_dir = fdroid_dir / repo_section repo_dir.mkdir(parents=True) - for filename in fdroidserver.deploy.INDEX_FILES: + fake_apk = 'Sym.apk' + fake_files = fdroidserver.deploy.INDEX_FILES + [fake_apk] + for filename in fake_files: fake_file = repo_dir / filename with fake_file.open('w') as fp: fp.write('not a real one, but has the right filename') @@ -1064,6 +1075,13 @@ class DeployTest(unittest.TestCase): (Path(verify_repo.working_tree_dir) / remote_file).exists() ) + # Should not have the APK file + remote_file = f"fdroid/{repo_section}/{fake_apk}" + if verify_repo.working_tree_dir is not None: + self.assertFalse( + (Path(verify_repo.working_tree_dir) / remote_file).exists() + ) + if __name__ == "__main__": os.chdir(os.path.dirname(__file__))