From 965a39e3bf3f789e5080425c3326839fe5e204e9 Mon Sep 17 00:00:00 2001 From: beelit94 Date: Fri, 4 Aug 2017 15:36:11 -0700 Subject: [PATCH] 1. test with more felxible string order 2. test with latest terraform --- .travis.yml | 2 +- test/test_terraform.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9843ea0..bb62e9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ python: - '3.6' before_install: sudo apt-get install unzip before_script: - - export TFVER=0.9.5 + - export TFVER=0.10.0 - export TFURL=https://releases.hashicorp.com/terraform/ - TFURL+=$TFVER - TFURL+="/terraform_" diff --git a/test/test_terraform.py b/test/test_terraform.py index 78c41e3..c7e5a3a 100644 --- a/test/test_terraform.py +++ b/test/test_terraform.py @@ -8,11 +8,10 @@ import os import logging import re import shutil +from itertools import combinations logging.basicConfig(level=logging.DEBUG) root_logger = logging.getLogger() -# ch = logging.StreamHandler(sys.stdout) -# root_logger.addHandler(ch) current_path = os.path.dirname(os.path.realpath(__file__)) STRING_CASES = [ @@ -169,19 +168,20 @@ class TestTerraform(object): assert 'test2' in out @pytest.mark.parametrize( - ("param", "param_str"), + ("param"), [ - ({}, ""), - ({'module': 'test2'}, "-module=test2"), - ({'module': 'test2', 'no_color': IsFlagged}, "-no-color -module=test2") + ({}), + ({'module': 'test2'}), ] ) - def test_output(self, param, param_str, string_logger): + def test_output(self, param, string_logger): tf = Terraform(working_dir=current_path, variables={'test_var': 'test'}) tf.apply('var_to_output') result = tf.output('test_output', **param) + regex = re.compile('terraform output (-module=test2 -json|-json -module=test2) test_output') + log_str = string_logger() if param: - assert 'terraform output -json {0} test_output'.format(param_str) in string_logger() + assert re.search(regex, log_str), log_str else: assert result == 'test'