all: Refactor to nonglobal file systems

Updates #2701
Fixes #2951
This commit is contained in:
Bjørn Erik Pedersen
2017-01-10 10:55:03 +01:00
parent 0ada405912
commit c71e1b106e
71 changed files with 2219 additions and 1731 deletions

View File

@@ -18,12 +18,14 @@ import (
"strings"
"testing"
"github.com/spf13/hugo/deps"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/hugofs"
"path/filepath"
toml "github.com/pelletier/go-toml"
"github.com/spf13/hugo/hugofs"
"github.com/spf13/hugo/source"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
@@ -677,31 +679,29 @@ func setupTestMenuState(t *testing.T) {
}
func setupMenuTests(t *testing.T, pageSources []source.ByteSource) *Site {
s := createTestSite(pageSources)
setupTestMenuState(t)
testSiteSetup(s, t)
return s
fs := hugofs.NewMem()
for _, src := range pageSources {
writeSource(t, fs, filepath.Join("content", src.Name), string(src.Content))
}
return buildSingleSite(t, deps.DepsCfg{Fs: fs}, BuildCfg{})
}
func createTestSite(pageSources []source.ByteSource) *Site {
hugofs.InitMemFs()
return &Site{
deps: newDeps(DepsCfg{}),
Source: &source.InMemorySource{ByteSource: pageSources},
Language: helpers.NewDefaultLanguage(),
}
}
func testSiteSetup(s *Site, t *testing.T) {
if err := buildSiteSkipRender(s); err != nil {
t.Fatalf("Sites build failed: %s", err)
}
}
func tomlToMap(s string) (map[string]interface{}, error) {
tree, err := toml.Load(s)