config: more tests for variable detector

This commit is contained in:
Mitchell Hashimoto 2014-05-23 22:12:48 -07:00
parent 1c9582ff38
commit 537fa6cc87
1 changed files with 16 additions and 0 deletions

View File

@ -32,6 +32,22 @@ func TestVariableDetectWalker(t *testing.T) {
} }
} }
func TestVariableDetectWalker_resource(t *testing.T) {
w := new(variableDetectWalker)
str := `foo ${ec2.foo.bar}`
if err := w.Primitive(reflect.ValueOf(str)); err != nil {
t.Fatalf("err: %s", err)
}
if len(w.Variables) != 1 {
t.Fatalf("bad: %#v", w.Variables)
}
if w.Variables["ec2.foo.bar"].(*ResourceVariable).FullKey() != "ec2.foo.bar" {
t.Fatalf("bad: %#v", w.Variables)
}
}
func TestVariableDetectWalker_bad(t *testing.T) { func TestVariableDetectWalker_bad(t *testing.T) {
w := new(variableDetectWalker) w := new(variableDetectWalker)