Parse tests that parsing succeeds for all types
This commit is contained in:
parent
23e6ebe938
commit
0cffcbd1d0
@ -3,11 +3,58 @@ package hcl
|
|||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParse(t *testing.T) {
|
func TestParse(t *testing.T) {
|
||||||
|
cases := []struct {
|
||||||
|
Name string
|
||||||
|
Err bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"comment.hcl",
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"multiple.hcl",
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"structure.hcl",
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"structure_basic.hcl",
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"structure_empty.hcl",
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"assign_deep.hcl",
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"complex.hcl",
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range cases {
|
||||||
|
d, err := ioutil.ReadFile(filepath.Join(fixtureDir, tc.Name))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = Parse(string(d))
|
||||||
|
if (err != nil) != tc.Err {
|
||||||
|
t.Fatalf("Input: %s\n\nError: %s", tc.Name, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Input string
|
Input string
|
||||||
Output *ObjectNode
|
Output *ObjectNode
|
||||||
@ -105,7 +152,6 @@ func TestParse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
"complex.hcl",
|
"complex.hcl",
|
||||||
nil,
|
nil,
|
||||||
@ -130,3 +176,4 @@ func TestParse(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user