terraform: context test for when provider is missing from state

This commit is contained in:
Mitchell Hashimoto 2015-04-20 14:54:25 -07:00
parent d0a6d78b97
commit de004d7183
2 changed files with 45 additions and 0 deletions

View File

@ -610,6 +610,43 @@ func TestContext2Plan_preventDestroy_destroyPlan(t *testing.T) {
}
}
func TestContext2Plan_providerAliasMissing(t *testing.T) {
m := testModule(t, "apply-provider-alias-missing")
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := &State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
Resources: map[string]*ResourceState{
"aws_instance.foo": &ResourceState{
Type: "aws_instance",
Provider: "aws.foo",
Primary: &InstanceState{
ID: "bar",
Attributes: map[string]string{
"require_new": "abc",
},
},
},
},
},
},
}
ctx := testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
State: state,
})
if _, err := ctx.Plan(); err == nil {
t.Fatal("should err")
}
}
func TestContext2Plan_computed(t *testing.T) {
m := testModule(t, "plan-computed")
p := testProvider("aws")

View File

@ -0,0 +1,8 @@
provider "aws" {
alias = "bar"
}
resource "aws_instance" "bar" {
foo = "bar"
provider = "aws.bar"
}