Skip to content

Commit

Permalink
work on test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
aerickson committed Aug 7, 2024
1 parent f814502 commit fd366ab
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tf_authoritative_scanner/wrapper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ def temp_tf_file():
os.remove(temp_file.name)


@pytest.fixture
def temp_tf_dir_empty():
temp_dir = tempfile.TemporaryDirectory()
yield temp_dir.name
temp_dir.cleanup()


@pytest.fixture
def temp_tf_dir_good(temp_tf_file):
temp_dir = tempfile.TemporaryDirectory()
Expand Down Expand Up @@ -80,3 +87,11 @@ def test_run_tfas_and_terraform_good(self, temp_tf_dir_good: str):
result = subprocess.run(["tfast", "plan"], cwd=temp_tf_dir_good, capture_output=True, text=True)
assert "Terraform has compared your real infrastructure" in result.stdout
assert result.returncode == 0

def test_run_tfas_and_terraform_empty(self, temp_tf_dir_empty: str):
result = subprocess.run(["tfast", "-A", "plan"], cwd=temp_tf_dir_empty, capture_output=True, text=True)
assert (
"No Terraform files found in the current directory. Please ensure you're in a directory with .tf files."
in result.stdout
)
assert result.returncode == 1

0 comments on commit fd366ab

Please sign in to comment.