Skip to content

Commit

Permalink
fix: Legacy upload sender not working with extra args (#574)
Browse files Browse the repository at this point in the history
* Add kwargs to LegacyUploadSender send_upload_data

* sender.send_upload_data pass arguments as kwargs
  • Loading branch information
tony-codecov authored Dec 6, 2024
1 parent 2f506fa commit 8510d4a
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 84 deletions.
40 changes: 20 additions & 20 deletions codecov_cli/services/upload/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,26 +133,26 @@ def do_upload_logic(

if not dry_run:
sending_result = sender.send_upload_data(
upload_data,
commit_sha,
token,
env_vars,
report_code,
upload_file_type,
name,
branch,
slug,
pull_request_number,
build_code,
build_url,
job_code,
flags,
ci_service,
git_service,
enterprise_url,
parent_sha,
upload_coverage,
args,
upload_data=upload_data,
commit_sha=commit_sha,
token=token,
env_vars=env_vars,
report_code=report_code,
upload_file_type=upload_file_type,
name=name,
branch=branch,
slug=slug,
pull_request_number=pull_request_number,
build_code=build_code,
build_url=build_url,
job_code=job_code,
flags=flags,
ci_service=ci_service,
git_service=git_service,
enterprise_url=enterprise_url,
parent_sha=parent_sha,
upload_coverage=upload_coverage,
args=args,
)
else:
logger.info("dry-run option activated. NOT sending data to Codecov.")
Expand Down
4 changes: 1 addition & 3 deletions codecov_cli/services/upload/legacy_upload_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ def send_upload_data(
commit_sha: str,
token: str,
env_vars: typing.Dict[str, str],
report_code: str = None,
upload_file_type: str = None,
name: typing.Optional[str] = None,
branch: typing.Optional[str] = None,
slug: typing.Optional[str] = None,
Expand All @@ -49,9 +47,9 @@ def send_upload_data(
job_code: typing.Optional[str] = None,
flags: typing.List[str] = None,
ci_service: typing.Optional[str] = None,
git_service: typing.Optional[str] = None,
enterprise_url: typing.Optional[str] = None,
args: dict = None,
**kwargs,
) -> UploadSendingResult:
params = {
"package": f"codecov-cli/{codecov_cli_version}",
Expand Down
6 changes: 5 additions & 1 deletion tests/helpers/test_upload_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,11 @@ def test_upload_sender_post_called_with_right_parameters_and_upload_coverage(
headers = {"Authorization": f"token {random_token}"}

sending_result = UploadSender().send_upload_data(
upload_collection, random_sha, random_token, upload_coverage=True, **named_upload_data
upload_collection,
random_sha,
random_token,
upload_coverage=True,
**named_upload_data,
)
assert sending_result.error is None
assert sending_result.warnings == []
Expand Down
120 changes: 60 additions & 60 deletions tests/services/upload/test_upload_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,26 @@ def test_do_upload_logic_happy_path_legacy_uploader(mocker):
)
mock_generate_upload_data.assert_called_with("coverage")
mock_send_upload_data.assert_called_with(
mock_generate_upload_data.return_value,
"commit_sha",
"token",
None,
"report_code",
"coverage",
"name",
"branch",
"slug",
"pr",
"build_code",
"build_url",
"job_code",
None,
"service",
"git_service",
None,
None,
False,
None,
upload_data=mock_generate_upload_data.return_value,
commit_sha="commit_sha",
token="token",
env_vars=None,
report_code="report_code",
upload_file_type="coverage",
name="name",
branch="branch",
slug="slug",
pull_request_number="pr",
build_code="build_code",
build_url="build_url",
job_code="job_code",
flags=None,
ci_service="service",
git_service="git_service",
enterprise_url=None,
parent_sha=None,
upload_coverage=False,
args=None,
)


Expand Down Expand Up @@ -219,26 +219,26 @@ def test_do_upload_logic_happy_path(mocker):
)
mock_generate_upload_data.assert_called_with("coverage")
mock_send_upload_data.assert_called_with(
mock_generate_upload_data.return_value,
"commit_sha",
"token",
None,
"report_code",
"coverage",
"name",
"branch",
"slug",
"pr",
"build_code",
"build_url",
"job_code",
None,
"service",
"git_service",
None,
None,
False,
None,
upload_data=mock_generate_upload_data.return_value,
commit_sha="commit_sha",
token="token",
env_vars=None,
report_code="report_code",
upload_file_type="coverage",
name="name",
branch="branch",
slug="slug",
pull_request_number="pr",
build_code="build_code",
build_url="build_url",
job_code="job_code",
flags=None,
ci_service="service",
git_service="git_service",
enterprise_url=None,
parent_sha=None,
upload_coverage=False,
args=None,
)


Expand Down Expand Up @@ -671,24 +671,24 @@ def test_do_upload_logic_happy_path_test_results(mocker):
)
mock_generate_upload_data.assert_called_with("test_results")
mock_send_upload_data.assert_called_with(
mock_generate_upload_data.return_value,
"commit_sha",
"token",
None,
"report_code",
"test_results",
"name",
"branch",
"slug",
"pr",
"build_code",
"build_url",
"job_code",
None,
"service",
"git_service",
None,
None,
False,
{"args": "fake_args"},
upload_data=mock_generate_upload_data.return_value,
commit_sha="commit_sha",
token="token",
env_vars=None,
report_code="report_code",
upload_file_type="test_results",
name="name",
branch="branch",
slug="slug",
pull_request_number="pr",
build_code="build_code",
build_url="build_url",
job_code="job_code",
flags=None,
ci_service="service",
git_service="git_service",
enterprise_url=None,
parent_sha=None,
upload_coverage=False,
args={"args": "fake_args"},
)

0 comments on commit 8510d4a

Please sign in to comment.