|
14 | 14 | create_commit, |
15 | 15 | get_dual_write_start_date, |
16 | 16 | get_or_create_commit, |
17 | | - update_commit, |
18 | 17 | ) |
19 | 18 | from sentry.releases.models import Commit, CommitFileChange |
20 | 19 | from sentry.testutils.cases import TestCase |
@@ -241,73 +240,6 @@ def test_get_or_create_commit_backfills_to_new_table(self): |
241 | 240 | assert new_commit.author == self.author |
242 | 241 |
|
243 | 242 |
|
244 | | -class UpdateCommitTest(TestCase): |
245 | | - def setUp(self): |
246 | | - super().setUp() |
247 | | - self.repo = Repository.objects.create( |
248 | | - name="test-repo", |
249 | | - organization_id=self.organization.id, |
250 | | - ) |
251 | | - self.author = CommitAuthor.objects.create( |
252 | | - organization_id=self.organization.id, |
253 | | - |
254 | | - name="Test Author", |
255 | | - ) |
256 | | - |
257 | | - def test_update_commit_with_dual_write(self): |
258 | | - """Test updating a commit updates both tables when new_commit is provided""" |
259 | | - old_commit = OldCommit.objects.create( |
260 | | - organization_id=self.organization.id, |
261 | | - repository_id=self.repo.id, |
262 | | - key="abc123", |
263 | | - message="Initial message", |
264 | | - author=self.author, |
265 | | - ) |
266 | | - new_commit = Commit.objects.create( |
267 | | - id=old_commit.id, |
268 | | - organization_id=self.organization.id, |
269 | | - repository_id=self.repo.id, |
270 | | - key="abc123", |
271 | | - message="Initial message", |
272 | | - author=self.author, |
273 | | - date_added=old_commit.date_added, |
274 | | - ) |
275 | | - update_commit(old_commit, new_commit, message="Updated message") |
276 | | - old_commit.refresh_from_db() |
277 | | - new_commit.refresh_from_db() |
278 | | - assert old_commit.message == "Updated message" |
279 | | - assert new_commit.message == "Updated message" |
280 | | - |
281 | | - def test_update_commit_atomic_transaction(self): |
282 | | - """Test that updates are atomic when dual write is enabled""" |
283 | | - old_commit = OldCommit.objects.create( |
284 | | - organization_id=self.organization.id, |
285 | | - repository_id=self.repo.id, |
286 | | - key="ghi789", |
287 | | - message="Initial message", |
288 | | - author=self.author, |
289 | | - ) |
290 | | - new_commit = Commit.objects.create( |
291 | | - id=old_commit.id, |
292 | | - organization_id=self.organization.id, |
293 | | - repository_id=self.repo.id, |
294 | | - key="ghi789", |
295 | | - message="Initial message", |
296 | | - author=self.author, |
297 | | - date_added=old_commit.date_added, |
298 | | - ) |
299 | | - with ( |
300 | | - patch.object(Commit, "update", side_effect=Exception("Update failed")), |
301 | | - pytest.raises(Exception, match="Update failed"), |
302 | | - ): |
303 | | - update_commit(old_commit, new_commit, message="Should fail") |
304 | | - |
305 | | - old_commit.refresh_from_db() |
306 | | - new_commit.refresh_from_db() |
307 | | - assert old_commit.message == "Initial message" |
308 | | - assert new_commit.message == "Initial message" |
309 | | - |
310 | | - |
311 | 243 | class CreateCommitFileChangeDualWriteTest(TestCase): |
312 | 244 | def setUp(self): |
313 | 245 | super().setUp() |
|
0 commit comments