Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit a5e67d4

Browse files
committed
Add unit test
1 parent fd8038b commit a5e67d4

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

graphql_api/tests/test_commit.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3323,3 +3323,70 @@ def test_bundle_analysis_asset_routes(self, get_storage_service):
33233323
"/login",
33243324
"/super/long/url/path",
33253325
]
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

Comments
 (0)