Address pull request feedback
This commit is contained in:
parent
4945f4591d
commit
99c67e5fe5
2 changed files with 16 additions and 14 deletions
|
@ -32,9 +32,9 @@ class IsNotFlagged:
|
||||||
|
|
||||||
class TerraformCommandError(subprocess.CalledProcessError):
|
class TerraformCommandError(subprocess.CalledProcessError):
|
||||||
def __init__(self, ret_code, cmd, out, err):
|
def __init__(self, ret_code, cmd, out, err):
|
||||||
super(TerraformCommandError, self).__init__(ret_code, cmd)
|
super(TerraformCommandError, self).__init__(ret_code, cmd)
|
||||||
self.out = out
|
self.out = out
|
||||||
self.err = err
|
self.err = err
|
||||||
|
|
||||||
class Terraform(object):
|
class Terraform(object):
|
||||||
"""
|
"""
|
||||||
|
@ -339,7 +339,8 @@ class Terraform(object):
|
||||||
full_value = kwargs.pop('full_value', False)
|
full_value = kwargs.pop('full_value', False)
|
||||||
name_provided = (len(args) > 0)
|
name_provided = (len(args) > 0)
|
||||||
kwargs['json'] = IsFlagged
|
kwargs['json'] = IsFlagged
|
||||||
kwargs['capture_output'] = True
|
if not kwargs.get('capture_output', True) is True:
|
||||||
|
raise ValueError('capture_output is required for this method')
|
||||||
|
|
||||||
ret, out, err = self.output_cmd(*args, **kwargs)
|
ret, out, err = self.output_cmd(*args, **kwargs)
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,9 @@ CMD_CASES = [
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
lambda x: x.cmd('plan', 'var_to_output', no_color=IsFlagged, var={'test_var': 'test'}) ,
|
lambda x: x.cmd('plan', 'var_to_output', no_color=IsFlagged, var={'test_var': 'test'}) ,
|
||||||
["doesn't need to do anything",
|
# Expected output varies by terraform version
|
||||||
"no\nactions need to be performed"],
|
["doesn't need to do anything", # Terraform < 0.10.7 (used in travis env)
|
||||||
|
"no\nactions need to be performed"], # Terraform >= 0.10.7
|
||||||
0,
|
0,
|
||||||
False,
|
False,
|
||||||
'',
|
'',
|
||||||
|
@ -141,13 +142,13 @@ class TestTerraform(object):
|
||||||
tf = Terraform(working_dir=current_path)
|
tf = Terraform(working_dir=current_path)
|
||||||
tf.init(folder)
|
tf.init(folder)
|
||||||
try:
|
try:
|
||||||
ret, out, err = method(tf)
|
ret, out, err = method(tf)
|
||||||
assert not expected_exception
|
assert not expected_exception
|
||||||
except TerraformCommandError as e:
|
except TerraformCommandError as e:
|
||||||
assert expected_exception
|
assert expected_exception
|
||||||
ret = e.returncode
|
ret = e.returncode
|
||||||
out = e.out
|
out = e.out
|
||||||
err = e.err
|
err = e.err
|
||||||
|
|
||||||
logs = string_logger()
|
logs = string_logger()
|
||||||
logs = logs.replace('\n', '')
|
logs = logs.replace('\n', '')
|
||||||
|
@ -158,9 +159,9 @@ class TestTerraform(object):
|
||||||
ok = True
|
ok = True
|
||||||
break
|
break
|
||||||
if not ok:
|
if not ok:
|
||||||
assert expected_output[0] in out
|
assert expected_output[0] in out
|
||||||
else:
|
else:
|
||||||
assert expected_output in out
|
assert expected_output in out
|
||||||
assert expected_ret_code == ret
|
assert expected_ret_code == ret
|
||||||
assert expected_logs in logs
|
assert expected_logs in logs
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue