|
| 1 | +from sentry.models import ( |
| 2 | + ArtifactBundle, |
| 3 | + DebugIdArtifactBundle, |
| 4 | + File, |
| 5 | + ProjectArtifactBundle, |
| 6 | + ReleaseArtifactBundle, |
| 7 | + ScheduledDeletion, |
| 8 | + SourceFileType, |
| 9 | +) |
| 10 | +from sentry.tasks.deletion.scheduled import run_deletion |
| 11 | +from sentry.testutils import TransactionTestCase |
| 12 | + |
| 13 | + |
| 14 | +class DeleteArtifactBundleTest(TransactionTestCase): |
| 15 | + def test_simple(self): |
| 16 | + org = self.create_organization() |
| 17 | + project = self.create_project(organization=org) |
| 18 | + release = self.create_release(version="1.0", project=project) |
| 19 | + dist = release.add_dist("android") |
| 20 | + artifact_bundle = self.create_artifact_bundle(org=org) |
| 21 | + ReleaseArtifactBundle.objects.create( |
| 22 | + organization_id=org.id, |
| 23 | + release_name=release.version, |
| 24 | + dist_name=dist.name, |
| 25 | + artifact_bundle=artifact_bundle, |
| 26 | + ) |
| 27 | + DebugIdArtifactBundle.objects.create( |
| 28 | + organization_id=org.id, |
| 29 | + debug_id="c29728de-4dbd-4c08-bd50-7509e1ee2535", |
| 30 | + source_file_type=SourceFileType.MINIFIED_SOURCE.value, |
| 31 | + artifact_bundle=artifact_bundle, |
| 32 | + ) |
| 33 | + ProjectArtifactBundle.objects.create( |
| 34 | + organization_id=org.id, project_id=project.id, artifact_bundle=artifact_bundle |
| 35 | + ) |
| 36 | + |
| 37 | + deletion = ScheduledDeletion.schedule(artifact_bundle, days=0) |
| 38 | + deletion.update(in_progress=True) |
| 39 | + |
| 40 | + with self.tasks(): |
| 41 | + run_deletion(deletion.id) |
| 42 | + |
| 43 | + assert not ArtifactBundle.objects.filter(id=artifact_bundle.id).exists() |
| 44 | + assert not ReleaseArtifactBundle.objects.filter(artifact_bundle=artifact_bundle).exists() |
| 45 | + assert not DebugIdArtifactBundle.objects.filter(artifact_bundle=artifact_bundle).exists() |
| 46 | + assert not ProjectArtifactBundle.objects.filter(artifact_bundle=artifact_bundle).exists() |
| 47 | + assert not File.objects.filter(id=artifact_bundle.file.id).exists() |
0 commit comments