2015-10-11 23:27:43 +00:00
|
|
|
package parser
|
|
|
|
|
2015-10-15 21:57:57 +00:00
|
|
|
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
|
|
|
|
2015-10-11 23:49:07 +00:00
|
|
|
if n.Pos().Line != 1 {
|
|
|
|
t.Errorf("AssignStatement position is wrong\n\twant: '%d'\n\tgot : '%d'", 1, n.Pos().Line)
|
|
|
|
}
|
2015-10-15 21:57:57 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|