mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Add a nested data dir test
Ref. a discussion.
This commit is contained in:
parent
83d03a5201
commit
e3e627e6b7
1 changed files with 17 additions and 0 deletions
|
@ -289,6 +289,23 @@ func TestDataDirCollidingMapsAndArrays(t *testing.T) {
|
|||
doTestDataDir(t, dd, expected, "theme", "mytheme")
|
||||
}
|
||||
|
||||
// https://discourse.gohugo.io/t/recursive-data-file-parsing/26192
|
||||
func TestDataDirNestedDirectories(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var dd dataDir
|
||||
dd.addSource("themes/mytheme/data/a.json", `["1", "2", "3"]`)
|
||||
dd.addSource("data/test1/20/06/a.json", `{ "artist" : "Michael Brecker" }`)
|
||||
dd.addSource("data/test1/20/05/b.json", `{ "artist" : "Charlie Parker" }`)
|
||||
|
||||
expected :=
|
||||
map[string]interface{}{
|
||||
"a": []interface{}{"1", "2", "3"},
|
||||
"test1": map[string]interface{}{"20": map[string]interface{}{"05": map[string]interface{}{"b": map[string]interface{}{"artist": "Charlie Parker"}}, "06": map[string]interface{}{"a": map[string]interface{}{"artist": "Michael Brecker"}}}}}
|
||||
|
||||
doTestDataDir(t, dd, expected, "theme", "mytheme")
|
||||
}
|
||||
|
||||
type dataDir struct {
|
||||
sources [][2]string
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue