Skip to content

Commit

Permalink
Tests: assert that test_targets use hash prefixes
Browse files Browse the repository at this point in the history
Make sure that hash prefixes are added when downloading a target
through the repository simulator.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
  • Loading branch information
MVrachev committed Oct 6, 2021
1 parent ee20dac commit c0b93f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/repository_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ def fetch(self, url: str) -> Iterator[bytes]:
path = spliturl.path[len("/targets/") :]
dir_parts, sep , prefixed_filename = path.rpartition("/")
prefix, _, filename = prefixed_filename.partition(".")
if prefix == "":
raise ValueError("File name must have hash prefix")
target_path = f"{dir_parts}{sep}{filename}"

yield self._fetch_target(target_path, prefix)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_updater_with_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ def test_targets(self, test_case_data: Tuple[str, str]):
[file_info]
)

# Assert consistent_snapshot is True and downloaded targets have prefix.
self.assertTrue(self.sim.root.consistent_snapshot)
self.assertTrue(updater.config.prefix_targets_with_hash)
# download target, assert it is in cache and content is correct
local_path = updater.download_target(file_info, self.targets_dir)
self.assertEqual(
Expand Down

0 comments on commit c0b93f5

Please sign in to comment.