terraform: test for variables in provider configs

This commit is contained in:
Mitchell Hashimoto 2014-10-18 14:13:14 -07:00
parent 0a5e06d62c
commit 914cb1d44c
2 changed files with 37 additions and 0 deletions

View File

@ -3782,6 +3782,36 @@ func TestContextPlan_multiple_taint(t *testing.T) {
}
}
func TestContextPlan_provider(t *testing.T) {
m := testModule(t, "plan-provider")
p := testProvider("aws")
p.DiffFn = testDiffFn
var value interface{}
p.ConfigureFn = func(c *ResourceConfig) error {
value, _ = c.Get("foo")
return nil
}
ctx := testContext(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
Variables: map[string]string{
"foo": "bar",
},
})
if _, err := ctx.Plan(nil); err != nil {
t.Fatalf("err: %s", err)
}
if value != "bar" {
t.Fatalf("bad: %#v", value)
}
}
func TestContextPlan_varMultiCountOne(t *testing.T) {
m := testModule(t, "plan-var-multi-count-one")
p := testProvider("aws")

View File

@ -0,0 +1,7 @@
variable "foo" {}
provider "aws" {
foo = "${var.foo}"
}
resource "aws_instance" "bar" {}