def test_push_should_not_print_gh_token(mock_git): mock_git.configure_mock(**{ 'push.side_effect': GitCommandError('gh--token', 1, b'gh--token', b'gh--token') }) with pytest.raises(GitError) as excinfo: push_new_version(gh_token='gh--token') assert 'gh--token' not in str(excinfo)
def test_push_should_not_print_auth_token(mock_gitlab, mock_git): mock_git.configure_mock( **{ "push.side_effect": GitCommandError("auth--token", 1, b"auth--token", b"auth--token") }) with pytest.raises(GitError) as excinfo: push_new_version(auth_token="auth--token") assert "auth--token" not in str(excinfo)
def test_push_new_version_with_maintenance_branch_creation(mock_git): with mock.patch( "semantic_release.history.config.get", wrapped_config_get(vcs_release_branch_format='r/{version_tag}')): push_new_version(new_version='1.0.0', branch="testing") mock_git.push.assert_has_calls([ mock.call("origin", "testing"), mock.call("--tags", "origin", "testing"), mock.call('origin', 'r/v1.0.0') ])
def test_push_should_not_print_auth_token(mock_git, mocker): mock_git.configure_mock( **{ "push.side_effect": GitCommandError( "auth--token", 1, b"auth--token", b"auth--token" ) } ) mocker.patch( "semantic_release.vcs_helpers.config.get", wrapped_config_get(**{"hvcs": "gitlab"}), ) with pytest.raises(GitError) as excinfo: push_new_version(auth_token="auth--token") assert "auth--token" not in str(excinfo)
def test_push_using_token(mock_git, mocker, actor): mocker.patch.dict(os.environ, {"GITHUB_ACTOR": actor} if actor else {}, clear=True) token = "auth--token" domain = "domain" owner = "owner" name = "name" branch = "main" push_new_version( auth_token=token, domain=domain, owner=owner, name=name, branch=branch ) server = ( f"https://{actor + ':' if actor else ''}{token}@{domain}/{owner}/{name}.git" ) mock_git.push.assert_has_calls( [ mock.call(server, branch), mock.call("--tags", server, branch), ] )
def test_push_ignoring_token(mock_git, mocker): mocker.patch( "semantic_release.vcs_helpers.config.get", wrapped_config_get(**{"ignore_token_for_push": True}), ) token = "auth--token" domain = "domain" owner = "owner" name = "name" branch = "main" push_new_version( auth_token=token, domain=domain, owner=owner, name=name, branch=branch ) server = "origin" mock_git.push.assert_has_calls( [ mock.call(server, branch), mock.call("--tags", server, branch), ] )
def test_push_new_version_with_custom_branch(mock_git): push_new_version(branch="release") mock_git.push.assert_has_calls([ mock.call('origin', 'release'), mock.call('--tags', 'origin', 'release'), ])
def test_push_new_version(mock_git): push_new_version() mock_git.push.assert_has_calls([ mock.call('origin', 'master'), mock.call('--tags', 'origin', 'master'), ])
def test_push_new_version_with_custom_branch(mock_git): push_new_version(branch="release") mock_git.push.assert_has_calls([ mock.call("origin", "release"), mock.call("--tags", "origin", "release"), ])
def test_push_new_version(mock_git): push_new_version() mock_git.push.assert_has_calls([ mock.call("origin", "master"), mock.call("--tags", "origin", "master"), ])
def test_push_new_version(mock_git): push_new_version() mock_git.push.assert_has_calls([ mock.call('origin', 'master'), mock.call('--tags', 'origin', 'master'), ])
def test_push_new_version(self, mock_run): push_new_version() mock_run.assert_called_with('git push && git push --tags', hide=True)