Merge branch 'b-missing-data-diff'

This commit is contained in:
James Nugent 2016-05-23 16:11:48 -05:00
commit bf91434576
3 changed files with 57 additions and 1 deletions

View File

@ -864,6 +864,53 @@ func TestContext2Plan_computed(t *testing.T) {
}
}
func TestContext2Plan_computedDataResource(t *testing.T) {
m := testModule(t, "plan-computed-data-resource")
p := testProvider("aws")
p.DiffFn = testDiffFn
ctx := testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
})
plan, err := ctx.Plan()
if err != nil {
t.Fatalf("err: %s", err)
}
if got := len(plan.Diff.Modules); got != 1 {
t.Fatalf("got %d modules; want 1", got)
}
moduleDiff := plan.Diff.Modules[0]
if _, ok := moduleDiff.Resources["aws_instance.foo"]; !ok {
t.Fatalf("missing diff for aws_instance.foo")
}
iDiff, ok := moduleDiff.Resources["data.aws_vpc.bar"]
if !ok {
t.Fatalf("missing diff for data.aws_vpc.bar")
}
expectedDiff := &InstanceDiff{
Attributes: map[string]*ResourceAttrDiff{
"id": {
NewComputed: true,
RequiresNew: true,
Type: DiffAttrOutput,
},
},
}
if same, _ := expectedDiff.Same(iDiff); !same {
t.Fatalf(
"incorrect diff for data.aws_vpc.bar\ngot: %#v\nwant: %#v",
iDiff, expectedDiff,
)
}
}
func TestContext2Plan_computedList(t *testing.T) {
m := testModule(t, "plan-computed-list")
p := testProvider("aws")

View File

@ -38,7 +38,8 @@ func (n *EvalReadDataDiff) Eval(ctx EvalContext) (interface{}, error) {
provider := *n.Provider
config := *n.Config
diff, err := provider.ReadDataDiff(n.Info, config)
var err error
diff, err = provider.ReadDataDiff(n.Info, config)
if err != nil {
return nil, err
}

View File

@ -0,0 +1,8 @@
resource "aws_instance" "foo" {
num = "2"
compute = "foo"
}
data "aws_vpc" "bar" {
foo = "${aws_instance.foo.foo}"
}