hcl/parser/parser_test.go

30 lines
496 B
Go
Raw Normal View History

2015-10-11 23:27:43 +00:00
package parser
import (
"fmt"
"testing"
)
2015-10-11 23:27:43 +00:00
2015-10-12 19:53:40 +00:00
func TestAssignStatement(t *testing.T) {
2015-10-11 23:27:43 +00:00
src := `ami = "${var.foo}"`
p := New([]byte(src))
p.enableTrace = true
2015-10-12 07:37:37 +00:00
n, err := p.Parse()
if err != nil {
t.Fatal(err)
}
2015-10-11 23:27:43 +00:00
if n.Pos().Line != 1 {
t.Errorf("AssignStatement position is wrong\n\twant: '%d'\n\tgot : '%d'", 1, n.Pos().Line)
}
n1, ok := n.(*ObjectList)
if !ok {
t.Fatal("First Node should be of type Source")
}
for _, ns := range n1.nodes {
fmt.Printf("ns = %+v\n", ns)
}
2015-10-11 23:27:43 +00:00
}