From 071d872dc273b2316dd2bd684d6ffcb34c797fe1 Mon Sep 17 00:00:00 2001 From: Emil Hessman Date: Mon, 12 Jan 2015 14:01:05 +0100 Subject: [PATCH] terraform: acceptance test for validation error Add an acceptance test where terraform plan should error due to validation errors. --- terraform/context_test.go | 16 ++++++++++++++++ .../test-fixtures/plan-var-list-err/main.tf | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 terraform/test-fixtures/plan-var-list-err/main.tf diff --git a/terraform/context_test.go b/terraform/context_test.go index 4045217ab..e5c2794a5 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -4148,6 +4148,22 @@ func TestContextPlan_varMultiCountOne(t *testing.T) { } } +func TestContextPlan_varListErr(t *testing.T) { + m := testModule(t, "plan-var-list-err") + p := testProvider("aws") + ctx := testContext(t, &ContextOpts{ + Module: m, + Providers: map[string]ResourceProviderFactory{ + "aws": testProviderFuncFixed(p), + }, + }) + + _, err := ctx.Plan(nil) + if err == nil { + t.Fatal("should error") + } +} + func TestContextRefresh(t *testing.T) { p := testProvider("aws") m := testModule(t, "refresh-basic") diff --git a/terraform/test-fixtures/plan-var-list-err/main.tf b/terraform/test-fixtures/plan-var-list-err/main.tf new file mode 100644 index 000000000..6303064c9 --- /dev/null +++ b/terraform/test-fixtures/plan-var-list-err/main.tf @@ -0,0 +1,16 @@ +provider "aws" { + access_key = "a" + secret_key = "b" + region = "us-east-1" +} + +resource "aws_instance" "foo" { + ami = "ami-foo" + instance_type = "t2.micro" + security_groups = "${aws_security_group.foo.name}" +} + +resource "aws_security_group" "foo" { + name = "foobar" + description = "foobar" +}