From 6bb3cb8f2f352e98cdfa660da984c70efcc44532 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 13 Feb 2015 12:13:39 -0800 Subject: [PATCH] terraform: a lot more passing tests --- terraform/context_old_test.go | 2 ++ terraform/context_test.go | 39 ++++++++++++++++++--------------- terraform/terraform_test.go | 10 +++++---- terraform/transform_resource.go | 2 +- 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/terraform/context_old_test.go b/terraform/context_old_test.go index 89942d60f..295f8284f 100644 --- a/terraform/context_old_test.go +++ b/terraform/context_old_test.go @@ -2213,6 +2213,7 @@ func TestContextApply_destroyTaintedProvisioner(t *testing.T) { } } +/* func TestContextApply_error(t *testing.T) { errored := false @@ -2338,6 +2339,7 @@ func TestContextApply_errorPartial(t *testing.T) { t.Fatalf("bad: \n%s", actual) } } +*/ func TestContextApply_hook(t *testing.T) { m := testModule(t, "apply-good") diff --git a/terraform/context_test.go b/terraform/context_test.go index 7517ba5ed..eb5b7a48e 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -3844,13 +3844,13 @@ func TestContext2Apply_destroy(t *testing.T) { } /* -func TestContextApply_destroyOutputs(t *testing.T) { +func TestContext2Apply_destroyOutputs(t *testing.T) { m := testModule(t, "apply-destroy-outputs") h := new(HookRecordApplyOrder) p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - ctx := testContext(t, &ContextOpts{ + ctx := testContext2(t, &ContextOpts{ Module: m, Hooks: []Hook{h}, Providers: map[string]ResourceProviderFactory{ @@ -3884,8 +3884,9 @@ func TestContextApply_destroyOutputs(t *testing.T) { t.Fatalf("bad: %#v", mod) } } +*/ -func TestContextApply_destroyOrphan(t *testing.T) { +func TestContext2Apply_destroyOrphan(t *testing.T) { m := testModule(t, "apply-error") p := testProvider("aws") s := &State{ @@ -3903,7 +3904,7 @@ func TestContextApply_destroyOrphan(t *testing.T) { }, }, } - ctx := testContext(t, &ContextOpts{ + ctx := testContext2(t, &ContextOpts{ Module: m, Providers: map[string]ResourceProviderFactory{ "aws": testProviderFuncFixed(p), @@ -3945,7 +3946,7 @@ func TestContextApply_destroyOrphan(t *testing.T) { } } -func TestContextApply_destroyTaintedProvisioner(t *testing.T) { +func TestContext2Apply_destroyTaintedProvisioner(t *testing.T) { m := testModule(t, "apply-destroy-provisioner") p := testProvider("aws") pr := testProvisioner() @@ -3979,7 +3980,7 @@ func TestContextApply_destroyTaintedProvisioner(t *testing.T) { }, } - ctx := testContext(t, &ContextOpts{ + ctx := testContext2(t, &ContextOpts{ Module: m, Providers: map[string]ResourceProviderFactory{ "aws": testProviderFuncFixed(p), @@ -4010,12 +4011,12 @@ func TestContextApply_destroyTaintedProvisioner(t *testing.T) { } } -func TestContextApply_error(t *testing.T) { +func TestContext2Apply_error(t *testing.T) { errored := false m := testModule(t, "apply-error") p := testProvider("aws") - ctx := testContext(t, &ContextOpts{ + ctx := testContext2(t, &ContextOpts{ Module: m, Providers: map[string]ResourceProviderFactory{ "aws": testProviderFuncFixed(p), @@ -4064,7 +4065,7 @@ func TestContextApply_error(t *testing.T) { } } -func TestContextApply_errorPartial(t *testing.T) { +func TestContext2Apply_errorPartial(t *testing.T) { errored := false m := testModule(t, "apply-error") @@ -4084,7 +4085,7 @@ func TestContextApply_errorPartial(t *testing.T) { }, }, } - ctx := testContext(t, &ContextOpts{ + ctx := testContext2(t, &ContextOpts{ Module: m, Providers: map[string]ResourceProviderFactory{ "aws": testProviderFuncFixed(p), @@ -4136,13 +4137,13 @@ func TestContextApply_errorPartial(t *testing.T) { } } -func TestContextApply_hook(t *testing.T) { +func TestContext2Apply_hook(t *testing.T) { m := testModule(t, "apply-good") h := new(MockHook) p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - ctx := testContext(t, &ContextOpts{ + ctx := testContext2(t, &ContextOpts{ Module: m, Hooks: []Hook{h}, Providers: map[string]ResourceProviderFactory{ @@ -4166,10 +4167,10 @@ func TestContextApply_hook(t *testing.T) { } } -func TestContextApply_idAttr(t *testing.T) { +func TestContext2Apply_idAttr(t *testing.T) { m := testModule(t, "apply-idattr") p := testProvider("aws") - ctx := testContext(t, &ContextOpts{ + ctx := testContext2(t, &ContextOpts{ Module: m, Providers: map[string]ResourceProviderFactory{ "aws": testProviderFuncFixed(p), @@ -4217,12 +4218,12 @@ func TestContextApply_idAttr(t *testing.T) { } } -func TestContextApply_output(t *testing.T) { +func TestContext2Apply_output(t *testing.T) { m := testModule(t, "apply-output") p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - ctx := testContext(t, &ContextOpts{ + ctx := testContext2(t, &ContextOpts{ Module: m, Providers: map[string]ResourceProviderFactory{ "aws": testProviderFuncFixed(p), @@ -4245,12 +4246,13 @@ func TestContextApply_output(t *testing.T) { } } -func TestContextApply_outputInvalid(t *testing.T) { +/* +func TestContext2Apply_outputInvalid(t *testing.T) { m := testModule(t, "apply-output-invalid") p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - ctx := testContext(t, &ContextOpts{ + ctx := testContext2(t, &ContextOpts{ Module: m, Providers: map[string]ResourceProviderFactory{ "aws": testProviderFuncFixed(p), @@ -4266,6 +4268,7 @@ func TestContextApply_outputInvalid(t *testing.T) { } } +/* func TestContextApply_outputList(t *testing.T) { m := testModule(t, "apply-output-list") p := testProvider("aws") diff --git a/terraform/terraform_test.go b/terraform/terraform_test.go index d6d8a305b..76526b680 100644 --- a/terraform/terraform_test.go +++ b/terraform/terraform_test.go @@ -337,8 +337,9 @@ const testTerraformApplyDestroyStr = ` ` const testTerraformApplyErrorStr = ` -aws_instance.bar: - ID = bar +aws_instance.bar: (1 tainted) + ID = + Tainted ID 1 = bar Dependencies: aws_instance.foo @@ -360,8 +361,9 @@ aws_instance.bar: (1 tainted) ` const testTerraformApplyErrorPartialStr = ` -aws_instance.bar: - ID = bar +aws_instance.bar: (1 tainted) + ID = + Tainted ID 1 = bar Dependencies: aws_instance.foo diff --git a/terraform/transform_resource.go b/terraform/transform_resource.go index 8afebd681..27918a8f9 100644 --- a/terraform/transform_resource.go +++ b/terraform/transform_resource.go @@ -238,7 +238,7 @@ func (n *graphNodeExpandedResource) EvalTree() EvalNode { &EvalIf{ If: func(ctx EvalContext) (bool, error) { if diffApply == nil { - return true, nil + return true, EvalEarlyExitError{} } if diffApply.Destroy {