Handle simple string slice
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
)
|
||||
|
||||
func TestFromAst_KV(t *testing.T) {
|
||||
t.Skipf("later")
|
||||
root := ast.Root{
|
||||
ast.Node{
|
||||
Kind: ast.KeyValue,
|
||||
@@ -37,3 +36,39 @@ func TestFromAst_KV(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, Doc{Foo: "hello"}, x)
|
||||
}
|
||||
|
||||
func TestFromAst_Slice(t *testing.T) {
|
||||
root := ast.Root{
|
||||
ast.Node{
|
||||
Kind: ast.KeyValue,
|
||||
Children: []ast.Node{
|
||||
{
|
||||
Kind: ast.Key,
|
||||
Data: []byte(`Foo`),
|
||||
},
|
||||
{
|
||||
Kind: ast.Array,
|
||||
Children: []ast.Node{
|
||||
{
|
||||
Kind: ast.String,
|
||||
Data: []byte(`hello`),
|
||||
},
|
||||
{
|
||||
Kind: ast.String,
|
||||
Data: []byte(`world`),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
type Doc struct {
|
||||
Foo []string
|
||||
}
|
||||
|
||||
x := Doc{}
|
||||
err := unmarshaler.FromAst(root, &x)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, Doc{Foo: []string{"hello", "world"}}, x)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user