File: test_git_main_master.py

package info (click to toggle)
thefuck 3.32-0.4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,132 kB
  • sloc: python: 12,011; makefile: 5; sh: 2
file content (47 lines) | stat: -rw-r--r-- 1,284 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pytest
from thefuck.rules.git_main_master import match, get_new_command
from thefuck.types import Command


@pytest.fixture
def output(branch_name):
    if not branch_name:
        return ""
    output_str = u"error: pathspec '{}' did not match any file(s) known to git"
    return output_str.format(branch_name)


@pytest.mark.parametrize(
    "script, branch_name",
    [
        ("git checkout main", "main"),
        ("git checkout master", "master"),
        ("git show main", "main"),
    ],
)
def test_match(script, branch_name, output):
    assert match(Command(script, output))


@pytest.mark.parametrize(
    "script, branch_name",
    [
        ("git checkout master", ""),
        ("git checkout main", ""),
        ("git checkout wibble", "wibble"),
    ],
)
def test_not_match(script, branch_name, output):
    assert not match(Command(script, output))


@pytest.mark.parametrize(
    "script, branch_name, new_command",
    [
        ("git checkout main", "main", "git checkout master"),
        ("git checkout master", "master", "git checkout main"),
        ("git checkout wibble", "wibble", "git checkout wibble"),
    ],
)
def test_get_new_command(script, branch_name, new_command, output):
    assert get_new_command(Command(script, output)) == new_command