Merge branch 'develop' into release/0.8.0

This commit is contained in:
Freddy Tan 2016-12-20 23:25:23 +08:00
commit c240d7e3b0
2 changed files with 14 additions and 8 deletions

View file

@ -11,9 +11,15 @@ python:
# command to install dependencies # command to install dependencies
before_install: 'sudo apt-get install unzip' before_install: 'sudo apt-get install unzip'
before_script: before_script:
- 'wget https://releases.hashicorp.com/terraform/0.7.11/terraform_0.7.11_linux_amd64.zip' - 'export TFVER=0.8.1'
- 'export TFURL=https://releases.hashicorp.com/terraform/'
- 'TFURL+=$TFVER'
- 'TFURL+="/terraform_"'
- 'TFURL+=$TFVER'
- 'TFURL+="_linux_amd64.zip"'
- 'wget $TFURL -O terraform_bin.zip'
- 'mkdir tf_bin' - 'mkdir tf_bin'
- 'unzip terraform_0.7.11_linux_amd64.zip -d tf_bin' - 'unzip terraform_bin.zip -d tf_bin'
install: install:
- "curl https://bootstrap.pypa.io/ez_setup.py -o - | python" - "curl https://bootstrap.pypa.io/ez_setup.py -o - | python"

View file

@ -50,7 +50,7 @@ class TestTerraform(object):
"method", "expected" "method", "expected"
], STRING_CASES) ], STRING_CASES)
def test_generate_cmd_string(self, method, expected): def test_generate_cmd_string(self, method, expected):
tf = Terraform() tf = Terraform(working_dir=current_path)
result = method(tf) result = method(tf)
strs = expected.split() strs = expected.split()
@ -73,7 +73,7 @@ class TestTerraform(object):
("var_to_output", {'test_map_var': {"c": "c", "d": "d"}}, 'var_to_output/test_map_var.json', "test_map_output={a=ab=bc=cd=de=ef=f}") ("var_to_output", {'test_map_var': {"c": "c", "d": "d"}}, 'var_to_output/test_map_var.json', "test_map_output={a=ab=bc=cd=de=ef=f}")
]) ])
def test_apply(self, folder, variables, var_files, expected_output): def test_apply(self, folder, variables, var_files, expected_output):
tf = Terraform(variables=variables, var_file=var_files) tf = Terraform(working_dir=current_path, variables=variables, var_file=var_files)
ret, out, err = tf.apply(folder) ret, out, err = tf.apply(folder)
assert ret == 0 assert ret == 0
assert expected_output in out.replace('\n', '').replace(' ', '') assert expected_output in out.replace('\n', '').replace(' ', '')
@ -98,24 +98,24 @@ class TestTerraform(object):
] ]
) )
def test_override_default(self, folder, variables): def test_override_default(self, folder, variables):
tf = Terraform(variables=variables) tf = Terraform(working_dir=current_path, variables=variables)
ret, out, err = tf.apply(folder, var={'test_var': 'test2'}, ret, out, err = tf.apply(folder, var={'test_var': 'test2'},
no_color=IsNotFlagged) no_color=IsNotFlagged)
out = out.replace('\n', '') out = out.replace('\n', '')
assert '\x1b[0m\x1b[1m\x1b[32mApply' in out assert '\x1b[0m\x1b[1m\x1b[32mApply' in out
def test_get_output(self): def test_get_output(self):
tf = Terraform(variables={'test_var': 'test'}) tf = Terraform(working_dir=current_path, variables={'test_var': 'test'})
tf.apply('var_to_output') tf.apply('var_to_output')
assert tf.output('test_output') == 'test' assert tf.output('test_output') == 'test'
def test_destroy(self): def test_destroy(self):
tf = Terraform(variables={'test_var': 'test'}) tf = Terraform(working_dir=current_path, variables={'test_var': 'test'})
ret, out, err = tf.destroy('var_to_output') ret, out, err = tf.destroy('var_to_output')
assert ret == 0 assert ret == 0
assert 'Destroy complete! Resources: 0 destroyed.' in out assert 'Destroy complete! Resources: 0 destroyed.' in out
def test_fmt(self): def test_fmt(self):
tf = Terraform(variables={'test_var': 'test'}) tf = Terraform(working_dir=current_path, variables={'test_var': 'test'})
ret, out, err = tf.fmt(diff=True) ret, out, err = tf.fmt(diff=True)
assert ret == 0 assert ret == 0