mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-31 07:04:12 +00:00 
			
		
		
		
	Added rules to run terraform init before terraform plan or apply (#924)
* Run terraform init to initialize terraform modules * Fix indent * Add unit tests for terraform_init.py
This commit is contained in:
		
				
					committed by
					
						 Vladimir Iakovlev
						Vladimir Iakovlev
					
				
			
			
				
	
			
			
			
						parent
						
							e047c1eb40
						
					
				
				
					commit
					4c3a559124
				
			
							
								
								
									
										33
									
								
								tests/rules/test_terraform_init.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								tests/rules/test_terraform_init.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| import pytest | ||||
| from thefuck.rules.terraform_init import match, get_new_command | ||||
| from thefuck.types import Command | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('script, output', [ | ||||
|     ('terraform plan', 'Error: Initialization required. ' | ||||
|                        'Please see the error message above.'), | ||||
|     ('terraform plan', 'This module is not yet installed. Run "terraform init" ' | ||||
|                        'to install all modules required by this configuration.'), | ||||
|     ('terraform apply', 'Error: Initialization required. ' | ||||
|                         'Please see the error message above.'), | ||||
|     ('terraform apply', 'This module is not yet installed. Run "terraform init" ' | ||||
|                         'to install all modules required by this configuration.')]) | ||||
| def test_match(script, output): | ||||
|     assert match(Command(script, output)) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('script, output', [ | ||||
|     ('terraform --version', 'Terraform v0.12.2'), | ||||
|     ('terraform plan', 'No changes. Infrastructure is up-to-date.'), | ||||
|     ('terraform apply', 'Apply complete! Resources: 0 added, 0 changed, 0 destroyed.'), | ||||
| ]) | ||||
| def test_not_match(script, output): | ||||
|     assert not match(Command(script, output=output)) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('command, new_command', [ | ||||
|     (Command('terraform plan', ''), 'terraform init && terraform plan'), | ||||
|     (Command('terraform apply', ''), 'terraform init && terraform apply'), | ||||
| ]) | ||||
| def test_get_new_command(command, new_command): | ||||
|     assert get_new_command(command) == new_command | ||||
		Reference in New Issue
	
	Block a user