mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-14 20:33:59 +02:00
Allow cascade _target to work with non toml fm
The TOML lib unmarshals slices of string maps to []map[string]interface{} whereas YAML and JSON decode to []interface{} The existing tests only check for TOML working correctly, and _target with cascade did not work at all for frontmatter defined in other formats. Add a function to normalize those slices Fixes #7874
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
fdfa4a5fe6
commit
3400aff258
@@ -75,6 +75,39 @@ func TestToLower(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestToSliceStringMap(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
||||
tests := []struct {
|
||||
input interface{}
|
||||
expected []map[string]interface{}
|
||||
}{
|
||||
{
|
||||
input: []map[string]interface{}{
|
||||
{"abc": 123},
|
||||
},
|
||||
expected: []map[string]interface{}{
|
||||
{"abc": 123},
|
||||
},
|
||||
}, {
|
||||
input: []interface{}{
|
||||
map[string]interface{}{
|
||||
"def": 456,
|
||||
},
|
||||
},
|
||||
expected: []map[string]interface{}{
|
||||
{"def": 456},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
v, err := ToSliceStringMap(test.input)
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(v, qt.DeepEquals, test.expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenameKeys(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
||||
|
Reference in New Issue
Block a user