Esempio n. 1
0
def test_get_version_has_commit(mocker, patched_run_command):
    mocker.patch("gilt.git._has_branch").return_value = False
    mocker.patch("gilt.git._has_tag").return_value = False
    mocker.patch("gilt.git._has_commit").return_value = True
    git._get_version("commit_sha")
    expected = [
        mocker.call(sh.git.bake("checkout", "commit_sha"), debug=False),
        mocker.call(sh.git.bake("clean", "-d", "-x", "-f"), debug=False),
    ]

    assert expected == patched_run_command.mock_calls
Esempio n. 2
0
def test_get_version_has_commit(mocker, patched_run_command):
    mocker.patch('gilt.git._has_branch').return_value = False
    mocker.patch('gilt.git._has_tag').return_value = False
    mocker.patch('gilt.git._has_commit').return_value = True
    git._get_version('commit_sha')
    # yapf: disable
    expected = [
        mocker.call(sh.git.bake('checkout', 'commit_sha'), debug=False),
        mocker.call(sh.git.bake('clean', '-d', '-x', '-f'), debug=False)
    ]
    # yapf: enable

    assert expected == patched_run_command.mock_calls
Esempio n. 3
0
def test_get_version_needs_pull(mocker, patched_run_command):
    mocker.patch("gilt.git._has_branch").side_effect = [False, True]
    mocker.patch("gilt.git._has_tag").return_value = False
    mocker.patch("gilt.git._has_commit").return_value = False
    git._get_version("remote_branch")
    expected = [
        mocker.call(sh.git.bake("fetch"), debug=False),
        mocker.call(sh.git.bake("checkout", "remote_branch"), debug=False),
        mocker.call(sh.git.bake("clean", "-d", "-x", "-f"), debug=False),
        mocker.call(sh.git.bake("pull", rebase=True, ff_only=True),
                    debug=False),
    ]

    assert expected == patched_run_command.mock_calls
Esempio n. 4
0
def test_get_version_needs_pull(mocker, patched_run_command):
    mocker.patch('gilt.git._has_branch').side_effect = [False, True]
    mocker.patch('gilt.git._has_tag').return_value = False
    mocker.patch('gilt.git._has_commit').return_value = False
    git._get_version('remote_branch')
    # yapf: disable
    expected = [
        mocker.call(sh.git.bake('fetch'), debug=False),
        mocker.call(sh.git.bake('checkout', 'remote_branch'), debug=False),
        mocker.call(sh.git.bake('clean', '-d', '-x', '-f'), debug=False),
        mocker.call(sh.git.bake('pull', rebase=True, ff_only=True),
                    debug=False)
    ]
    # yapf: enable

    assert expected == patched_run_command.mock_calls