mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-25 22:00:58 +02:00
Reads data files inside data/ and makes data available in .Site.Data
Fixes #476. Conflicts: hugolib/site.go
This commit is contained in:
committed by
bep
parent
4c7e119ca1
commit
773812de6f
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -745,3 +746,18 @@ func TestWeightedTaxonomies(t *testing.T) {
|
||||
t.Errorf("Pages in unexpected order, 'bza' expected first, got '%v'", s.Taxonomies["categories"]["e"][0].Page.Title)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDataDir(t *testing.T) {
|
||||
sources := []source.ByteSource{
|
||||
{filepath.FromSlash("test" + string(os.PathSeparator) + "foo.yaml"), []byte("bar: foofoo")},
|
||||
{filepath.FromSlash("test.yaml"), []byte("hello:\n- world: foo")},
|
||||
}
|
||||
|
||||
s := &Site{}
|
||||
s.loadData(&source.InMemorySource{ByteSource: sources})
|
||||
|
||||
expected := "map[test:map[hello:[map[world:foo]] foo:map[bar:foofoo]]]"
|
||||
if fmt.Sprint(s.Data) != expected {
|
||||
t.Errorf("Expected structure '%s', got '%s'", expected, s.Data)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user