-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add create commit to empty-upload command
This is so that we can also create the commit before uploading. The create-commit is optional (i.e. if users don't pass in values, then their workflow shouldn't break). It will only create a commit if the values are passed.
- Loading branch information
1 parent
079f01b
commit f9c8a47
Showing
2 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from click.testing import CliRunner | ||
|
||
from codecov_cli.fallbacks import FallbackFieldEnum | ||
from codecov_cli.main import cli | ||
from tests.factory import FakeProvider, FakeVersioningSystem | ||
|
||
def test_invoke_empty_upload_with_create_commit(mocker): | ||
create_commit_mock = mocker.patch("codecov_cli.commands.empty_upload.create_commit_logic") | ||
empty_upload_mock = mocker.patch("codecov_cli.commands.empty_upload.empty_upload_logic") | ||
|
||
fake_ci_provider = FakeProvider({FallbackFieldEnum.commit_sha: None}) | ||
mocker.patch("codecov_cli.main.get_ci_adapter", return_value=fake_ci_provider) | ||
|
||
runner = CliRunner() | ||
result = runner.invoke(cli, ["empty-upload", | ||
"-C", "command-sha", | ||
"--slug", "owner/repo", | ||
"--parent-sha", "asdf", | ||
"--branch", "main", | ||
"--pr", 1234], obj={}) | ||
assert result.exit_code == 0 | ||
|
||
create_commit_mock.assert_called_once() | ||
empty_upload_mock.assert_called_once() | ||
|
||
def test_invoke_empty_upload_no_create_commit(mocker): | ||
create_commit_mock = mocker.patch("codecov_cli.commands.empty_upload.create_commit_logic") | ||
empty_upload_mock = mocker.patch("codecov_cli.commands.empty_upload.empty_upload_logic") | ||
|
||
fake_ci_provider = FakeProvider({FallbackFieldEnum.commit_sha: None}) | ||
mocker.patch("codecov_cli.main.get_ci_adapter", return_value=fake_ci_provider) | ||
|
||
runner = CliRunner() | ||
result = runner.invoke(cli, ["empty-upload", | ||
"-C", "command-sha", | ||
"--slug", "owner/repo"], obj={}) | ||
assert result.exit_code == 0 | ||
|
||
create_commit_mock.assert_not_called() | ||
empty_upload_mock.assert_called_once() | ||
|