Testing Git Add Force Command Handling in TheFuck
This test suite validates the functionality of the git_add_force rule in TheFuck, which handles cases where files are ignored by .gitignore but need to be forcefully added. The tests ensure proper command transformation when users attempt to add ignored files.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
nvbn/thefuck
tests/rules/test_git_add_force.py
import pytest
from thefuck.rules.git_add_force import match, get_new_command
from thefuck.types import Command
@pytest.fixture
def output():
return ('The following paths are ignored by one of your .gitignore files:
'
'dist/app.js
'
'dist/background.js
'
'dist/options.js
'
'Use -f if you really want to add them.
')
def test_match(output):
assert match(Command('git add dist/*.js', output))
assert not match(Command('git add dist/*.js', ''))
def test_get_new_command(output):
assert (get_new_command(Command('git add dist/*.js', output))
== "git add --force dist/*.js")