1313from sentry .models .releaseheadcommit import ReleaseHeadCommit
1414from sentry .models .repository import Repository
1515from sentry .silo .base import SiloMode
16- from sentry .tasks .commits import fetch_commits , handle_invalid_identity
16+ from sentry .tasks .commits import (
17+ fetch_commits ,
18+ get_github_compare_commits_cache_key ,
19+ handle_invalid_identity ,
20+ )
1721from sentry .testutils .asserts import assert_slo_metric
1822from sentry .testutils .cases import TestCase
1923from sentry .testutils .silo import assume_test_silo_mode , control_silo_test
@@ -30,6 +34,14 @@ def _github_compare_commits_result(self, repo_name: str, end_sha: str) -> list[d
3034 {"id" : end_sha , "repository" : repo_name },
3135 ]
3236
37+ def test_github_compare_commits_cache_key_avoids_ambiguous_id_collisions (
38+ self , mock_record : MagicMock
39+ ) -> None :
40+ key_one = get_github_compare_commits_cache_key (1 , 23 , "integrations:github" , "a" , "b" )
41+ key_two = get_github_compare_commits_cache_key (12 , 3 , "integrations:github" , "a" , "b" )
42+
43+ assert key_one != key_two
44+
3345 def _test_simple_action (self , user , org ):
3446 repo = Repository .objects .create (name = "example" , provider = "dummy" , organization_id = org .id )
3547 release = Release .objects .create (organization_id = org .id , version = "abcabcabc" )
0 commit comments