Skip to content

Commit 62e4364

Browse files
committed
Add a test for add_target_to_bin that adds a fileinfo
Add some additional checks to test_add_target_to_bin to ensure the code to add a target passing a fileinfo is tested. Signed-off-by: Joshua Lock <[email protected]>
1 parent 8609927 commit 62e4364

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test_repository_tool.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,20 @@ def test_add_target_to_bin(self):
14851485
self.targets_object.add_target_to_bin,
14861486
os.path.basename(target1_filepath), 16)
14871487

1488+
# Test adding a target with fileinfo
1489+
target2_hashes = {'sha256': '517c0ce943e7274a2431fa5751e17cfd5225accd23e479bfaad13007751e87ef'}
1490+
target2_fileinfo = tuf.formats.make_fileinfo(37, target2_hashes)
1491+
target2_filepath = os.path.join(self.targets_directory, 'file2.txt')
1492+
1493+
self.targets_object.add_target_to_bin(os.path.basename(target2_filepath), 16, fileinfo=target2_fileinfo)
1494+
1495+
for delegation in self.targets_object.delegations:
1496+
if delegation.rolename == '0':
1497+
self.assertTrue('file2.txt' in delegation.target_files)
1498+
1499+
else:
1500+
self.assertFalse('file2.txt' in delegation.target_files)
1501+
14881502
# Test improperly formatted argument.
14891503
self.assertRaises(securesystemslib.exceptions.FormatError,
14901504
self.targets_object.add_target_to_bin, 3, 'foo')

0 commit comments

Comments
 (0)