Merge branch 'release/0.8.1'

merge-requests/1/head 0.8.1
Freddy Tan 8 years ago
commit 331249029f

@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.8.0
current_version = 0.8.1
commit = True
tag = False

@ -1 +1 @@
0.8.0
0.8.1

@ -51,7 +51,7 @@ class Terraform(object):
self.terraform_bin_path = terraform_bin_path \
if terraform_bin_path else 'terraform'
self.var_file = var_file
self.temp_var_files = VaribleFiles()
self.temp_var_files = VariableFiles()
# store the tfstate data
self.tfstate = None
@ -59,7 +59,7 @@ class Terraform(object):
def __getattr__(self, item):
def wrapper(*args, **kwargs):
print('called with %r and %r' % (args, kwargs))
logging.debug('called with %r and %r' % (args, kwargs))
return self.cmd(item, *args, **kwargs)
return wrapper
@ -152,12 +152,12 @@ class Terraform(object):
if v is IsNotFlagged:
continue
if not v:
continue
if type(v) is bool:
v = 'true' if v else 'false'
if not v:
continue
cmds += ['-{k}={v}'.format(k=k, v=v)]
cmds += args
@ -239,7 +239,7 @@ class Terraform(object):
self.temp_var_files.clean_up()
class VaribleFiles(object):
class VariableFiles(object):
def __init__(self):
self.files = []

@ -0,0 +1,31 @@
variable "test_var" {
default = ""
}
provider "archive" {}
variable "test_list_var" {
type = "list"
default = ["a", "b"]
}
variable "test_map_var" {
type = "map"
default = {
"a" = "a"
"b" = "b"
}
}
output "test_output" {
value = "${var.test_var}"
}
output "test_list_output" {
value = "${var.test_list_var}"
}
output "test_map_output" {
value = "${var.test_map_var}"
}

@ -3,6 +3,7 @@ import pytest
import os
import logging
import re
import shutil
logging.basicConfig(level=logging.DEBUG)
current_path = os.path.dirname(os.path.realpath(__file__))
@ -31,6 +32,19 @@ CMD_CASES = [
]
]
@pytest.fixture()
def fmt_test_file(request):
target = os.path.join(current_path, 'bad_fmt', 'test.backup')
orgin = os.path.join(current_path, 'bad_fmt', 'test.tf')
shutil.copy(orgin,
target)
def td():
shutil.move(target, orgin)
request.addfinalizer(td)
return
class TestTerraform(object):
def teardown_method(self, method):
@ -79,6 +93,18 @@ class TestTerraform(object):
assert expected_output in out.replace('\n', '').replace(' ', '')
assert err == ''
@pytest.mark.parametrize(
['cmd', 'args', 'options'],
[
# bool value
('fmt', ['bad_fmt'], {'list': False, 'diff': False})
]
)
def test_options(self, cmd, args, options, fmt_test_file):
tf = Terraform(working_dir=current_path)
ret, out, err = getattr(tf, cmd)(*args, **options)
assert ret == 0
assert out == ''
def test_state_data(self):
cwd = os.path.join(current_path, 'test_tfstate_file')

Loading…
Cancel
Save