From 3db22d0de01e6a7ae355fe7a8798d311743abd99 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 9 Feb 2015 16:08:00 -0800 Subject: [PATCH] terraform: move more tests --- terraform/context_test.go | 84 +++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/terraform/context_test.go b/terraform/context_test.go index f89fda0cc..841098499 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -453,6 +453,48 @@ func TestContext2Validate_selfRefMultiAll(t *testing.T) { } } +func TestContext2Validate_tainted(t *testing.T) { + p := testProvider("aws") + m := testModule(t, "validate-good") + state := &State{ + Modules: []*ModuleState{ + &ModuleState{ + Path: rootModulePath, + Resources: map[string]*ResourceState{ + "aws_instance.foo": &ResourceState{ + Type: "aws_instance", + Tainted: []*InstanceState{ + &InstanceState{ + ID: "bar", + }, + }, + }, + }, + }, + }, + } + c := testContext2(t, &ContextOpts{ + Module: m, + Providers: map[string]ResourceProviderFactory{ + "aws": testProviderFuncFixed(p), + }, + State: state, + }) + + p.ValidateResourceFn = func( + t string, c *ResourceConfig) ([]string, []error) { + return nil, c.CheckSet([]string{"foo"}) + } + + w, e := c.Validate() + if len(w) > 0 { + t.Fatalf("bad: %#v", w) + } + if len(e) > 0 { + t.Fatalf("bad: %#v", e) + } +} + func TestContext2Validate_varRef(t *testing.T) { m := testModule(t, "validate-variable-ref") p := testProvider("aws") @@ -524,48 +566,6 @@ func TestContextValidate_moduleProviderInherit(t *testing.T) { } } -func TestContextValidate_tainted(t *testing.T) { - p := testProvider("aws") - m := testModule(t, "validate-good") - state := &State{ - Modules: []*ModuleState{ - &ModuleState{ - Path: rootModulePath, - Resources: map[string]*ResourceState{ - "aws_instance.foo": &ResourceState{ - Type: "aws_instance", - Tainted: []*InstanceState{ - &InstanceState{ - ID: "bar", - }, - }, - }, - }, - }, - }, - } - c := testContext(t, &ContextOpts{ - Module: m, - Providers: map[string]ResourceProviderFactory{ - "aws": testProviderFuncFixed(p), - }, - State: state, - }) - - p.ValidateResourceFn = func( - t string, c *ResourceConfig) ([]string, []error) { - return nil, c.CheckSet([]string{"foo"}) - } - - w, e := c.Validate() - if len(w) > 0 { - t.Fatalf("bad: %#v", w) - } - if len(e) > 0 { - t.Fatalf("bad: %#v", e) - } -} - func TestContextInput(t *testing.T) { input := new(MockUIInput) m := testModule(t, "input-vars")