mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	#1302: Add new git_clone_missing rule
* Add git clone missing rule * Clean up tests and improve matching * Make rules behave correctly? * Improve tests and redo matcher * Remove unnecessary tests * Improvements as per code review * Remove dead tests * Improve match function for git clone missing * Improve tests * Fix more tests * Fix failing test * Add Macos's /bin/sh command output to match * Add output for lines uncovered by tests Co-authored-by: Pablo Santiago Blum de Aguiar <scorphus@gmail.com>
This commit is contained in:
		
							
								
								
									
										50
									
								
								tests/rules/test_git_clone_missing.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								tests/rules/test_git_clone_missing.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| import pytest | ||||
| from thefuck.rules.git_clone_missing import match, get_new_command | ||||
| from thefuck.types import Command | ||||
|  | ||||
| valid_urls = [ | ||||
|     'https://github.com/nvbn/thefuck.git', | ||||
|     'https://github.com/nvbn/thefuck', | ||||
|     'http://github.com/nvbn/thefuck.git', | ||||
|     'git@github.com:nvbn/thefuck.git', | ||||
|     'git@github.com:nvbn/thefuck', | ||||
|     'ssh://git@github.com:nvbn/thefuck.git', | ||||
| ] | ||||
| invalid_urls = [ | ||||
|     '',  # No command | ||||
|     'notacommand',  # Command not found | ||||
|     'ssh git@github.com:nvbn/thefrick.git',  # ssh command, not a git clone | ||||
|     'git clone foo',  # Valid clone | ||||
|     'git clone https://github.com/nvbn/thefuck.git',  # Full command | ||||
|     'github.com/nvbn/thefuck.git',  # Missing protocol | ||||
|     'github.com:nvbn/thefuck.git',  # SSH missing username | ||||
|     'git clone git clone ssh://git@github.com:nvbn/thefrick.git',  # 2x clone | ||||
|     'https:/github.com/nvbn/thefuck.git'  # Bad protocol | ||||
| ] | ||||
| outputs = [ | ||||
|     'No such file or directory', | ||||
|     'not found', | ||||
|     'is not recognised as', | ||||
| ] | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('cmd', valid_urls) | ||||
| @pytest.mark.parametrize('output', outputs) | ||||
| def test_match(cmd, output): | ||||
|     c = Command(cmd, output) | ||||
|     assert match(c) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('cmd', invalid_urls) | ||||
| @pytest.mark.parametrize('output', outputs + ["some other output"]) | ||||
| def test_not_match(cmd, output): | ||||
|     c = Command(cmd, output) | ||||
|     assert not match(c) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('script', valid_urls) | ||||
| @pytest.mark.parametrize('output', outputs) | ||||
| def test_get_new_command(script, output): | ||||
|     command = Command(script, output) | ||||
|     new_command = 'git clone ' + script | ||||
|     assert get_new_command(command) == new_command | ||||
		Reference in New Issue
	
	Block a user