diff options
-rw-r--r-- | hugolib/datafiles_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/hugolib/datafiles_test.go b/hugolib/datafiles_test.go index 699cf9cd8..294dc8379 100644 --- a/hugolib/datafiles_test.go +++ b/hugolib/datafiles_test.go @@ -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 } |