Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
marcciosilva committed Jun 6, 2024
1 parent 3b4af6a commit be2e599
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
15 changes: 13 additions & 2 deletions terraform_pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@

import click

from terraform_pytest.constants import TF_REPO_PATH, TF_TEST_BINARY_PATH, TERRATEST_PROJECT_FOLDER
from terraform_pytest.utils import build_test_binary, get_services, patch_repository, run_terratest_tests
from terraform_pytest.constants import (
TF_REPO_PATH,
TF_TEST_BINARY_PATH,
TERRATEST_PROJECT_FOLDER,
)
from terraform_pytest.utils import (
build_test_binary,
get_services,
patch_repository,
run_terratest_tests,
)

logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -63,6 +72,7 @@ def clean_command():
os.remove(os.path.join(TF_TEST_BINARY_PATH, file))
logging.info("Done")


@click.command(name="terratest-tests", help="Run Golang Terratest tests")
def terratest_tests():
logging.info(f"Running terratest tests from {TERRATEST_PROJECT_FOLDER} directory")
Expand All @@ -73,6 +83,7 @@ def terratest_tests():
except Exception as e:
logging.error(f"Failed to execute terratest tests: {str(e)}")


if __name__ == "__main__":
cli.add_command(build_command)
cli.add_command(patch_command)
Expand Down
8 changes: 7 additions & 1 deletion terraform_pytest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ def execute_command(

try:
process = subprocess.run(
cmd, env=env_vars, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
cmd,
env=env_vars,
cwd=cwd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
return_code = process.returncode
output = process.stdout + "\n" + process.stderr
Expand Down Expand Up @@ -156,6 +161,7 @@ def patch_repository():
if stdout:
logging.info(f"{patch_file} has been patched successfully.")


def run_terratest_tests(terratest_path: str) -> Tuple[int, str]:
"""
Run the Golang Terratest tests for the specified project.
Expand Down

0 comments on commit be2e599

Please sign in to comment.