|
7 | 7 | from sentry.models.commit import Commit as OldCommit |
8 | 8 | from sentry.models.commitauthor import CommitAuthor |
9 | 9 | from sentry.models.repository import Repository |
10 | | -from sentry.releases.commits import create_commit, get_or_create_commit |
| 10 | +from sentry.releases.commits import create_commit |
11 | 11 | from sentry.releases.models import Commit |
12 | 12 | from sentry.testutils.cases import TestCase |
13 | 13 |
|
@@ -143,90 +143,3 @@ def test_create_commit_transaction_atomicity(self): |
143 | 143 | ) |
144 | 144 | assert not OldCommit.objects.filter(key="test_atomicity_key").exists() |
145 | 145 | assert not Commit.objects.filter(key="test_atomicity_key").exists() |
146 | | - |
147 | | - |
148 | | -class GetOrCreateCommitDualWriteTest(TestCase): |
149 | | - def setUp(self): |
150 | | - super().setUp() |
151 | | - self.repo = Repository.objects.create( |
152 | | - name="test-repo", |
153 | | - organization_id=self.organization.id, |
154 | | - ) |
155 | | - self.author = CommitAuthor.objects.create( |
156 | | - organization_id=self.organization.id, |
157 | | - |
158 | | - name="Test Author", |
159 | | - ) |
160 | | - |
161 | | - def test_get_or_create_commit_creates_new(self): |
162 | | - """Test that get_or_create creates a new commit when it doesn't exist""" |
163 | | - old_commit, new_commit, created = get_or_create_commit( |
164 | | - organization=self.organization, |
165 | | - repo_id=self.repo.id, |
166 | | - key="new123", |
167 | | - message="New commit message", |
168 | | - author=self.author, |
169 | | - ) |
170 | | - |
171 | | - assert created is True |
172 | | - assert old_commit.key == "new123" |
173 | | - assert old_commit.message == "New commit message" |
174 | | - assert old_commit.author == self.author |
175 | | - |
176 | | - assert new_commit is not None |
177 | | - assert new_commit.id == old_commit.id |
178 | | - assert new_commit.key == "new123" |
179 | | - assert new_commit.message == "New commit message" |
180 | | - assert new_commit.author == self.author |
181 | | - |
182 | | - def test_get_or_create_commit_gets_existing(self): |
183 | | - """Test that get_or_create returns existing commit when it exists""" |
184 | | - existing_old, existing_new = create_commit( |
185 | | - organization=self.organization, |
186 | | - repo_id=self.repo.id, |
187 | | - key="existing456", |
188 | | - message="Existing commit", |
189 | | - author=self.author, |
190 | | - ) |
191 | | - assert existing_new is not None |
192 | | - old_commit, new_commit, created = get_or_create_commit( |
193 | | - organization=self.organization, |
194 | | - repo_id=self.repo.id, |
195 | | - key="existing456", |
196 | | - message="This should not be used", |
197 | | - author=None, |
198 | | - ) |
199 | | - assert created is False |
200 | | - assert old_commit.id == existing_old.id |
201 | | - assert old_commit.key == "existing456" |
202 | | - assert old_commit.message == "Existing commit" |
203 | | - assert old_commit.author == self.author |
204 | | - assert new_commit is not None |
205 | | - assert new_commit.id == existing_new.id |
206 | | - |
207 | | - def test_get_or_create_commit_backfills_to_new_table(self): |
208 | | - """Test that get_or_create backfills to new table if commit exists only in old table""" |
209 | | - old_only_commit = OldCommit.objects.create( |
210 | | - organization_id=self.organization.id, |
211 | | - repository_id=self.repo.id, |
212 | | - key="old_only789", |
213 | | - message="Old table only", |
214 | | - author=self.author, |
215 | | - ) |
216 | | - assert not Commit.objects.filter(id=old_only_commit.id).exists() |
217 | | - |
218 | | - old_commit, new_commit, created = get_or_create_commit( |
219 | | - organization=self.organization, |
220 | | - repo_id=self.repo.id, |
221 | | - key="old_only789", |
222 | | - message="Should not be used", |
223 | | - ) |
224 | | - |
225 | | - assert created is False |
226 | | - assert old_commit.id == old_only_commit.id |
227 | | - assert old_commit.message == "Old table only" |
228 | | - assert new_commit is not None |
229 | | - assert new_commit.id == old_only_commit.id |
230 | | - assert new_commit.key == "old_only789" |
231 | | - assert new_commit.message == "Old table only" |
232 | | - assert new_commit.author == self.author |
0 commit comments