terraform: failling test case for a bug

This commit is contained in:
Mitchell Hashimoto 2014-10-18 14:36:34 -07:00
parent 914cb1d44c
commit dc3178e06a
2 changed files with 52 additions and 0 deletions

View File

@ -777,6 +777,51 @@ func TestContextInput_providerOnly(t *testing.T) {
}
}
func TestContextInput_providerVars(t *testing.T) {
input := new(MockUIInput)
m := testModule(t, "input-provider-with-vars")
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
ctx := testContext(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
Variables: map[string]string{
"foo": "bar",
},
UIInput: input,
})
input.InputReturnMap = map[string]string{}
var actual interface{}
p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) {
return c, nil
}
p.ConfigureFn = func(c *ResourceConfig) error {
actual, _ = c.Get("foo")
return nil
}
if err := ctx.Input(InputModeStd); err != nil {
t.Fatalf("err: %s", err)
}
if _, err := ctx.Plan(nil); err != nil {
t.Fatalf("err: %s", err)
}
if _, err := ctx.Apply(); err != nil {
t.Fatalf("err: %s", err)
}
if !reflect.DeepEqual(actual, "bar") {
t.Fatalf("bad: %#v", actual)
}
}
func TestContextInput_varOnly(t *testing.T) {
input := new(MockUIInput)
m := testModule(t, "input-provider-vars")

View File

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