|
6 | 6 |
|
7 | 7 | import yaml |
8 | 8 | from django.test import TransactionTestCase |
| 9 | +from shared.api_archive.archive import ArchiveService |
9 | 10 | from shared.bundle_analysis import StoragePaths |
10 | 11 | from shared.bundle_analysis.storage import get_bucket_name |
11 | 12 | from shared.django_apps.core.tests.factories import ( |
|
30 | 31 | UploadFactory, |
31 | 32 | UploadFlagMembershipFactory, |
32 | 33 | ) |
33 | | -from services.archive import ArchiveService |
34 | 34 | from services.comparison import MissingComparisonReport |
35 | 35 | from services.components import Component |
36 | 36 | from services.profiling import CriticalFile |
@@ -3323,3 +3323,70 @@ def test_bundle_analysis_asset_routes(self, get_storage_service): |
3323 | 3323 | "/login", |
3324 | 3324 | "/super/long/url/path", |
3325 | 3325 | ] |
| 3326 | + |
| 3327 | + @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service") |
| 3328 | + def test_bundle_analysis_report_info(self, get_storage_service): |
| 3329 | + storage = MemoryStorageService({}) |
| 3330 | + get_storage_service.return_value = storage |
| 3331 | + |
| 3332 | + head_commit_report = CommitReportFactory( |
| 3333 | + commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS |
| 3334 | + ) |
| 3335 | + |
| 3336 | + with open( |
| 3337 | + "./services/tests/samples/bundle_with_assets_and_modules.sqlite", "rb" |
| 3338 | + ) as f: |
| 3339 | + storage_path = StoragePaths.bundle_report.path( |
| 3340 | + repo_key=ArchiveService.get_archive_hash(self.repo), |
| 3341 | + report_key=head_commit_report.external_id, |
| 3342 | + ) |
| 3343 | + storage.write_file(get_bucket_name(), storage_path, f) |
| 3344 | + |
| 3345 | + query = """ |
| 3346 | + query FetchCommit($org: String!, $repo: String!, $commit: String!) { |
| 3347 | + owner(username: $org) { |
| 3348 | + repository(name: $repo) { |
| 3349 | + ... on Repository { |
| 3350 | + commit(id: $commit) { |
| 3351 | + bundleAnalysis { |
| 3352 | + bundleAnalysisReport { |
| 3353 | + __typename |
| 3354 | + ... on BundleAnalysisReport { |
| 3355 | + bundle(name: "b5") { |
| 3356 | + info { |
| 3357 | + version |
| 3358 | + plugin_name |
| 3359 | + plugin_version |
| 3360 | + built_at |
| 3361 | + duration |
| 3362 | + bundler_name |
| 3363 | + bundler_version |
| 3364 | + } |
| 3365 | + } |
| 3366 | + } |
| 3367 | + } |
| 3368 | + } |
| 3369 | + } |
| 3370 | + } |
| 3371 | + } |
| 3372 | + } |
| 3373 | + } |
| 3374 | + """ |
| 3375 | + |
| 3376 | + variables = { |
| 3377 | + "org": self.org.username, |
| 3378 | + "repo": self.repo.name, |
| 3379 | + "commit": self.commit.commitid, |
| 3380 | + } |
| 3381 | + data = self.gql_request(query, variables=variables) |
| 3382 | + commit = data["owner"]["repository"]["commit"] |
| 3383 | + |
| 3384 | + bundle_info = commit["bundleAnalysis"]["bundleAnalysisReport"]["bundle"]["info"] |
| 3385 | + |
| 3386 | + assert bundle_info["version"] == "1" |
| 3387 | + assert bundle_info["plugin_name"] == "codecov-vite-bundle-analysis-plugin" |
| 3388 | + assert bundle_info["plugin_version"] == "1.0.0" |
| 3389 | + assert bundle_info["built_at"] == "2023-12-01 17:17:28.604000" |
| 3390 | + assert bundle_info["duration"] == 331 |
| 3391 | + assert bundle_info["bundler_name"] == "rollup" |
| 3392 | + assert bundle_info["bundler_version"] == "3.29.4" |
0 commit comments