1
1
from django .urls import reverse
2
2
3
- from sentry .models .commit import Commit
3
+ from sentry .models .commitcomparison import CommitComparison
4
4
from sentry .preprod .models import PreprodArtifact
5
5
from sentry .testutils .cases import APITestCase
6
6
@@ -18,10 +18,16 @@ def setUp(self) -> None:
18
18
19
19
self .file = self .create_file (name = "test_artifact.apk" , type = "application/octet-stream" )
20
20
21
- self . commit = Commit .objects .create (
21
+ commit_comparison = CommitComparison .objects .create (
22
22
organization_id = self .org .id ,
23
- repository_id = 1 ,
24
- key = "abcdef1234567890" ,
23
+ head_sha = "1234567890098765432112345678900987654321" ,
24
+ base_sha = "9876543210012345678998765432100123456789" ,
25
+ provider = "github" ,
26
+ head_repo_name = "owner/repo" ,
27
+ base_repo_name = "owner/repo" ,
28
+ head_ref = "feature/xyz" ,
29
+ base_ref = "main" ,
30
+ pr_number = 123 ,
25
31
)
26
32
27
33
self .preprod_artifact = PreprodArtifact .objects .create (
@@ -35,7 +41,7 @@ def setUp(self) -> None:
35
41
build_number = 42 ,
36
42
build_configuration_id = None ,
37
43
installable_app_file_id = 1234 ,
38
- commit = self . commit ,
44
+ commit_comparison = commit_comparison ,
39
45
)
40
46
41
47
# Enable the feature flag for all tests by default
@@ -68,9 +74,6 @@ def test_get_build_details_success(self) -> None:
68
74
assert resp_data ["app_info" ]["version" ] == self .preprod_artifact .build_version
69
75
assert resp_data ["app_info" ]["build_number" ] == self .preprod_artifact .build_number
70
76
assert resp_data ["app_info" ]["artifact_type" ] == self .preprod_artifact .artifact_type
71
- assert resp_data ["vcs_info" ]["commit_id" ] == (
72
- self .preprod_artifact .commit .key if self .preprod_artifact .commit is not None else None
73
- )
74
77
75
78
def test_get_build_details_not_found (self ) -> None :
76
79
url = self ._get_url (artifact_id = 999999 )
@@ -108,12 +111,6 @@ def test_get_build_details_dates_and_types(self) -> None:
108
111
assert isinstance (resp_data ["app_info" ]["artifact_type" ], int )
109
112
110
113
def test_get_build_details_vcs_info (self ) -> None :
111
- new_commit = Commit .objects .create (
112
- organization_id = self .org .id ,
113
- repository_id = 1 ,
114
- key = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" ,
115
- )
116
- self .preprod_artifact .commit = new_commit
117
114
self .preprod_artifact .save ()
118
115
119
116
url = self ._get_url ()
@@ -122,4 +119,11 @@ def test_get_build_details_vcs_info(self) -> None:
122
119
)
123
120
assert response .status_code == 200
124
121
resp_data = response .json ()
125
- assert resp_data ["vcs_info" ]["commit_id" ] == "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
122
+ assert resp_data ["vcs_info" ]["head_sha" ] == "1234567890098765432112345678900987654321"
123
+ assert resp_data ["vcs_info" ]["base_sha" ] == "9876543210012345678998765432100123456789"
124
+ assert resp_data ["vcs_info" ]["provider" ] == "github"
125
+ assert resp_data ["vcs_info" ]["head_repo_name" ] == "owner/repo"
126
+ assert resp_data ["vcs_info" ]["base_repo_name" ] == "owner/repo"
127
+ assert resp_data ["vcs_info" ]["head_ref" ] == "feature/xyz"
128
+ assert resp_data ["vcs_info" ]["base_ref" ] == "main"
129
+ assert resp_data ["vcs_info" ]["pr_number" ] == 123
0 commit comments