github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/config/lang/ast/call_test.go (about)

     1  package ast
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestCallType(t *testing.T) {
     8  	c := &Call{Func: "foo"}
     9  	scope := &BasicScope{
    10  		FuncMap: map[string]Function{
    11  			"foo": Function{ReturnType: TypeString},
    12  		},
    13  	}
    14  
    15  	actual, err := c.Type(scope)
    16  	if err != nil {
    17  		t.Fatalf("err: %s", err)
    18  	}
    19  	if actual != TypeString {
    20  		t.Fatalf("bad: %s", actual)
    21  	}
    22  }
    23  
    24  func TestCallType_invalid(t *testing.T) {
    25  	c := &Call{Func: "bar"}
    26  	scope := &BasicScope{
    27  		FuncMap: map[string]Function{
    28  			"foo": Function{ReturnType: TypeString},
    29  		},
    30  	}
    31  
    32  	_, err := c.Type(scope)
    33  	if err == nil {
    34  		t.Fatal("should error")
    35  	}
    36  }