Skip to content

Commit 7cc1b7b

Browse files
committed
Update integration tests to support shorter hashes
1 parent d3e245f commit 7cc1b7b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/integration/test_source_cache.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ def check_package_cache(name, ver, dir_sha1)
7575
assert_equal ver, package.ver
7676
expected_parent_dir = File.join(@cache_dir, name.downcase)
7777
assert package.src_dir.start_with?(expected_parent_dir), "#{package.src_dir} must be in #{expected_parent_dir}"
78-
assert_equal dir_sha1, File.basename(package.src_dir)
78+
79+
# The hash has been shortened by cpm_get_shortest_hash. The following
80+
# should hold:
81+
# - The short hash should be a prefix of the input hash
82+
# - There should be a file ".../${short_hash}.hash" which matches the full hash
83+
short_hash = File.basename(package.src_dir)
84+
assert dir_sha1.start_with?(short_hash), "short_hash should be a prefix of dir_sha1"
85+
86+
# Check that the full hash is stored in the .hash file
87+
hash_file = "#{package.src_dir}.hash"
88+
assert File.exist?(hash_file), "Hash file #{hash_file} should exist"
89+
assert_equal dir_sha1, File.read(hash_file), "Hash file should contain the full original hash"
7990
end
8091
end

0 commit comments

Comments
 (0)