diff --git a/tests/test_tftest.py b/tests/test_tftest.py index dd125d0..10c7696 100644 --- a/tests/test_tftest.py +++ b/tests/test_tftest.py @@ -21,22 +21,28 @@ _ARGS_TESTS = ( + ({'auto_approve': True}, ['-auto-approve']), ({'auto_approve': False}, []), ({'backend': True}, []), ({'backend': None}, []), ({'backend': False}, ['-backend=false']), ({'color': True}, []), - ({'input': True}, []), - ({'json_format': False}, []), - ({'lock': True}, []), - ({'plugin_dir': ''}, []), - ({'auto_approve': True}, ['-auto-approve']), ({'color': False}, ['-no-color']), + ({'color': False, 'input': False}, ['-no-color', '-input=false']), + ({'force_copy': True}, ['-force-copy']), + ({'force_copy': None}, []), + ({'force_copy': False}, []), + ({'input': True}, []), ({'input': False}, ['-input=false']), ({'json_format': True}, ['-json']), + ({'json_format': False}, []), + ({'lock': True}, []), ({'lock': False}, ['-lock=false']), + ({'plugin_dir': ''}, []), ({'plugin_dir': 'abc'}, ['-plugin-dir', 'abc']), - ({'color': False, 'input': False}, ['-no-color', '-input=false']) + ({'refresh': True}, []), + ({'refresh': None}, []), + ({'refresh': False}, ['-refresh=false']), ) _AUTORUN_CALLS = [ ['terraform', 'init', '-no-color', '-input=false'], diff --git a/tftest.py b/tftest.py index 7d1a388..52906e7 100644 --- a/tftest.py +++ b/tftest.py @@ -63,6 +63,8 @@ def parse_args(init_vars=None, tf_vars=None, **kw): cmd_args.append('-backend=false') if kw.get('color') is False: cmd_args.append('-no-color') + if kw.get('force_copy'): + cmd_args.append('-force-copy') if kw.get('input') is False: cmd_args.append('-input=false') if kw.get('json_format') is True: @@ -71,6 +73,8 @@ def parse_args(init_vars=None, tf_vars=None, **kw): cmd_args.append('-lock=false') if kw.get('plugin_dir'): cmd_args += ['-plugin-dir', kw['plugin_dir']] + if kw.get('refresh') is False: + cmd_args.append('-refresh=false') if isinstance(init_vars, dict): cmd_args += ['-backend-config=\'{}={}\''.format(k, v) for k, v in init_vars.items()] @@ -282,15 +286,18 @@ def teardown(self, tf_vars=None): except TerraformTestError: _LOGGER.exception('error in teardown destroy') - def init(self, input=False, color=False, plugin_dir=None, init_vars=None, backend=True): + def init(self, input=False, color=False, force_copy=False, plugin_dir=None, + init_vars=None, backend=True): """Run Terraform init command.""" cmd_args = parse_args(input=input, color=color, backend=backend, - plugin_dir=plugin_dir, init_vars=init_vars) + force_copy=force_copy, plugin_dir=plugin_dir, + init_vars=init_vars) return self.execute_command('init', *cmd_args).out - def plan(self, input=False, color=False, tf_vars=None): + def plan(self, input=False, color=False, refresh=True, tf_vars=None): """Run Terraform plan command.""" - cmd_args = parse_args(input=input, color=color, tf_vars=tf_vars) + cmd_args = parse_args(input=input, color=color, + refresh=refresh, tf_vars=tf_vars) return self.execute_command('plan', *cmd_args).out def apply(self, input=False, color=False, auto_approve=True, tf_vars=None):