Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pytest_terraform/tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def __init__(

def apply(self, plan=True):
"""run terraform apply"""
if plan is True:
if plan:
plan_path = os.path.join(self.work_dir, "tfplan")
self.plan(plan_path)
apply_args = self._get_cmd_args("apply", plan=plan_path)
elif plan:
else:
apply_args = self._get_cmd_args("apply", plan="")
try:
self._run_cmd(apply_args)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ def test_tf_statejson_update_bad():


@pytest.mark.skipif(not shutil.which("terraform"), reason="Terraform binary missing")
def test_tf_runner(testdir, tmpdir):
@pytest.mark.parametrize("plan", (True, False))
def test_tf_runner(testdir, tmpdir, plan):
# ** requires network access to install plugin **
with open(tmpdir.join("resources.tf"), "w") as fh:
fh.write(
Expand All @@ -165,7 +166,7 @@ def test_tf_runner(testdir, tmpdir):

trunner = tf.TerraformRunner(tmpdir.strpath, tf_bin=shutil.which("terraform"))
trunner.init()
state = trunner.apply()
state = trunner.apply(plan=plan)
assert state.get("foo")["content"] == "foo!"
with open(tmpdir.join("foo.bar")) as fh:
assert fh.read() == "foo!"
Expand Down