github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/config/lang/ast/scope_test.go (about) 1 package ast 2 3 import ( 4 "testing" 5 ) 6 7 func TestBasicScope_impl(t *testing.T) { 8 var _ Scope = new(BasicScope) 9 } 10 11 func TestBasicScopeLookupFunc(t *testing.T) { 12 scope := &BasicScope{ 13 FuncMap: map[string]Function{ 14 "foo": Function{}, 15 }, 16 } 17 18 if _, ok := scope.LookupFunc("bar"); ok { 19 t.Fatal("should not find bar") 20 } 21 if _, ok := scope.LookupFunc("foo"); !ok { 22 t.Fatal("should find foo") 23 } 24 } 25 26 func TestBasicScopeLookupVar(t *testing.T) { 27 scope := &BasicScope{ 28 VarMap: map[string]Variable{ 29 "foo": Variable{}, 30 }, 31 } 32 33 if _, ok := scope.LookupVar("bar"); ok { 34 t.Fatal("should not find bar") 35 } 36 if _, ok := scope.LookupVar("foo"); !ok { 37 t.Fatal("should find foo") 38 } 39 }