Testing Git Rebase Merge Directory Handling in TheFuck
This test suite validates the git_rebase_merge_dir rule functionality in TheFuck project, focusing on handling git rebase conflicts and directory management. The tests ensure proper detection and resolution of rebase-merge directory scenarios.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
nvbn/thefuck
tests/rules/test_git_rebase_merge_dir.py
import pytest
from thefuck.rules.git_rebase_merge_dir import match, get_new_command
from thefuck.types import Command
@pytest.fixture
def output():
return ('
It seems that there is already a rebase-merge directory, and
'
'I wonder if you are in the middle of another rebase. If that is the
'
'case, please try
'
'\tgit rebase (--continue | --abort | --skip)
'
'If that is not the case, please
'
'\trm -fr "/foo/bar/baz/egg/.git/rebase-merge"
'
'and run me again. I am stopping in case you still have something
'
'valuable there.
')
@pytest.mark.parametrize('script', [
'git rebase master',
'git rebase -skip',
'git rebase'])
def test_match(output, script):
assert match(Command(script, output))
@pytest.mark.parametrize('script', ['git rebase master', 'git rebase -abort'])
def test_not_match(script):
assert not match(Command(script, ''))
@pytest.mark.parametrize('script, result', [
('git rebase master', [
'git rebase --abort', 'git rebase --skip', 'git rebase --continue',
'rm -fr "/foo/bar/baz/egg/.git/rebase-merge"']),
('git rebase -skip', [
'git rebase --skip', 'git rebase --abort', 'git rebase --continue',
'rm -fr "/foo/bar/baz/egg/.git/rebase-merge"']),
('git rebase', [
'git rebase --skip', 'git rebase --abort', 'git rebase --continue',
'rm -fr "/foo/bar/baz/egg/.git/rebase-merge"'])])
def test_get_new_command(output, script, result):
assert get_new_command(Command(script, output)) == result