From b739004102473fcd295ee1a1922705401c1a4ee7 Mon Sep 17 00:00:00 2001 From: Freddy Tan Date: Fri, 18 Nov 2016 15:46:05 +0800 Subject: [PATCH] add travis --- .travis.yml | 16 ++++++++ test/test_terraform.py | 2 +- test/test_tfstate_file/tfstate.test | 62 +++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 .travis.yml create mode 100644 test/test_tfstate_file/tfstate.test diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5735476 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: python +python: + - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "3.5" +# - "3.5-dev" # 3.5 development branch +# - "3.6-dev" # 3.6 development branch +# - "nightly" # currently points to 3.7-dev +# command to install dependencies +#install: "pip install -r requirements.txt" +# command to run tests +script: + - cd test + - pytest \ No newline at end of file diff --git a/test/test_terraform.py b/test/test_terraform.py index e0c8bb9..5ad0d15 100644 --- a/test/test_terraform.py +++ b/test/test_terraform.py @@ -69,7 +69,7 @@ class TestTerraform: assert ret == 0 def test_state_data(self): - tf = Terraform(working_dir='test_tfstate_file') + tf = Terraform(working_dir='test_tfstate_file', state='tfstate.test') tf.read_state_file() assert tf.tfstate.modules[0]['path'] == ['root'] diff --git a/test/test_tfstate_file/tfstate.test b/test/test_tfstate_file/tfstate.test new file mode 100644 index 0000000..2e07061 --- /dev/null +++ b/test/test_tfstate_file/tfstate.test @@ -0,0 +1,62 @@ +{ + "version": 3, + "terraform_version": "0.7.10", + "serial": 0, + "lineage": "d03ecdf7-8be0-4593-a952-1d8127875119", + "modules": [ + { + "path": [ + "root" + ], + "outputs": {}, + "resources": { + "aws_instance.ubuntu-1404": { + "type": "aws_instance", + "depends_on": [], + "primary": { + "id": "i-84d10edb", + "attributes": { + "ami": "ami-9abea4fb", + "associate_public_ip_address": "true", + "availability_zone": "us-west-2b", + "disable_api_termination": "false", + "ebs_block_device.#": "0", + "ebs_optimized": "false", + "ephemeral_block_device.#": "0", + "iam_instance_profile": "", + "id": "i-84d10edb", + "instance_state": "running", + "instance_type": "t2.micro", + "key_name": "", + "monitoring": "false", + "network_interface_id": "eni-46544f07", + "private_dns": "ip-172-31-25-244.us-west-2.compute.internal", + "private_ip": "172.31.25.244", + "public_dns": "ec2-35-162-30-219.us-west-2.compute.amazonaws.com", + "public_ip": "35.162.30.219", + "root_block_device.#": "1", + "root_block_device.0.delete_on_termination": "true", + "root_block_device.0.iops": "100", + "root_block_device.0.volume_size": "8", + "root_block_device.0.volume_type": "gp2", + "security_groups.#": "0", + "source_dest_check": "true", + "subnet_id": "subnet-d2c0f0a6", + "tags.%": "0", + "tenancy": "default", + "vpc_security_group_ids.#": "1", + "vpc_security_group_ids.619359045": "sg-9fc7dcfd" + }, + "meta": { + "schema_version": "1" + }, + "tainted": false + }, + "deposed": [], + "provider": "" + } + }, + "depends_on": [] + } + ] +}